Skip to content

Instantly share code, notes, and snippets.

View SteelPh0enix's full-sized avatar
🅱️
yeet

Wojciech Olech SteelPh0enix

🅱️
yeet
View GitHub Profile
#include <iostream>
int main() {
int user_data;
std::cin >> user_data;
std::cout << "You have entered " << user_data << std::endl;
return 0;
}
#include <iostream>
#include <cmath>
int main() {
int x = 4.2 * std::pow(10., 9.);
unsigned int y = 4.2 * std::pow(10., 9.);
std::cout << x << ", " << y << std::endl;
return 0;
}
#include <iostream>
int main() {
int binary {0b101010};
int octal {0734};
unsigned int hexadecimal {0xDEADBEEF};
int decimal {1234};
std::cout << binary << std::endl
<< octal << std::endl
#include <iostream>
int main() {
//pomijam binarny zapis, ze względu na brak manipulatora dla niego
int octal {0734};
unsigned int hexadecimal {0xDEADBEEF};
int decimal {1234};
std::cout << std::oct << octal << std::endl
<< std::hex << hexadecimal << std::endl
@SteelPh0enix
SteelPh0enix / rule_of_five.cpp
Last active July 7, 2017 13:45
fixed << overloads, moved b == nullptr check to A class << overload
#include <iostream>
#include <utility> //std::move
struct B {
int x;
B() : x(0) { std::cout << "B constructed with default c-tor at " << this << std::endl; }
B(int new_x) : x(new_x) { std::cout << "B constructed with parametrized c-tor: " << *this << std::endl; }
~B() { std::cout << "Deleting B at " << this << "..." << std::endl; }
@SteelPh0enix
SteelPh0enix / logical_1.cpp
Last active July 12, 2017 07:32
little prettier
#include <iostream>
int main() {
//tworzymy i inicjalizujemy dwie zmienne o typie bool
bool x {true}, y {false};
//tworzymy zmienną 'z' i inicjalizujemy ją zanegowaną wartoscią zmiennej x (czyli false)
bool z {!x};
//przypisujemy zmiennej 'x' wartosc wyrazenia y OR z, czyli false (poniewaz ani y ani z nie mają wartosci true)
#include <iostream>
int main() {
unsigned short x{1024}, y{0};
std::cout << "!x = " << !x << std::endl
<< "~x = " << ~x << std::endl;
std::cout << "!y = " << !y << std::endl
<< "~y = " << ~y << std::endl;
#include <iostream>
int main() {
unsigned short x{1024}, y{0};
std::cout << "!x = " << !x << std::endl
<< "~x = " << static_cast<unsigned short>(~x) << std::endl;
std::cout << "!y = " << !y << std::endl
<< "~y = " << static_cast<unsigned short>(~y) << std::endl;
#include <iostream>
int main() {
int x{10}, y{25};
std::cout << "x = " << x << ", y = " << y << std::endl
<< "x & y = " << (x & y) << std::endl
<< "x | y = " << (x | y) << std::endl
<< "x ^ y = " << (x ^ y) << std::endl;
#include <iostream>
int main() {
int x{0b10110};
std::cout << "x = " << x << std::endl
<< "x << 1 = " << (x << 1) << std::endl
<< "x << 2 = " << (x << 2) << std::endl
<< "x << 3 = " << (x << 3) << std::endl
<< "x >> 1 = " << (x >> 1) << std::endl