Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SYSTEM CZWÓRKOWY
- #include <iostream>
- using namespace std;
- int main()
- {
- short int n;
- cout << "Podaj liczbe do zamiany na system czworkowy: ";
- cin >> n;
- for ( unsigned short int i = 0xc000, p=14 ; i > 0; i >>= 2 , p -= 2 )
- {
- cout << ((n&i) >> p); // n&i - iloczyn bitowy
- }
- cout << endl;
- system("pause");
- }
- /*
- //SYSTEM SZESNASTKOWY
- #include <iostream>
- using namespace std;
- int main()
- {
- short int n;
- cout << "Podaj liczbe do zamiany na system szesnastkowy: ";
- cin >> n;
- for ( short int i = 0x8000; i>0 ; i >>=1 )
- {
- cout << (n&i ? '1':'0'); // n&i - iloczyn bitowy
- }
- cout << "#16: " << hex << n;
- cout << endl;
- system("pause");
- }
- */
- /*
- //ZADANIE 1
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, suma = 0;
- cout << "Podaj liczbe: ";
- cin >> n;
- for( n ; n>0 ; )
- {
- suma = suma + n%10;
- n = n/10;
- }
- cout << endl << suma;
- system("pause");
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement