Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void Test(int *p, int x)
- {
- for (int i = 0; i <16; i++)
- {
- if(x&(1<<i))
- p[i] = 1;
- else
- p[i] = 0;
- }
- }
- void write(int *p)
- {
- for (int i = 15; i >=0; i--)
- {
- cout << p[i];
- }
- }
- int main()
- {
- int * p = new int[16];
- cout << "Zadejte dekadicke cislo: ";
- short int x;
- cin >>x;
- Test(p, x);
- cout << "Binarne: ",
- write(p);
- cout << endl;
- cout << "Hexadecimalne: " << hex << x << endl;
- cout << "Dekadicky (unsigned): " << dec << (unsigned short int) x << endl;
- cout << "Dekadicky (int): " << dec <<x;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement