Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <sstream>
- using namespace std;
- string str;
- bool dzielenie = true;
- int i;
- int l;
- main()
- {
- cout << "podaj liczbe dziesietna: ";
- cin >> l;
- while(dzielenie)
- {
- if(l < 16)
- {
- dzielenie = false;
- }
- //cout << l%2;
- //stringstream ss;
- //ss << l%2;
- //string str = ss.str();
- //str = to_string(l%2) + str;
- switch(l%16)
- {
- case 0:
- str = "0" + str; break;
- case 1:
- str = "1" + str; break;
- case 2:
- str = "2" + str; break;
- case 3:
- str = "3" + str; break;
- case 4:
- str = "4" + str; break;
- case 5:
- str = "5" + str; break;
- case 6:
- str = "6" + str; break;
- case 7:
- str = "7" + str; break;
- case 8:
- str = "8" + str; break;
- case 9:
- str = "9" + str; break;
- case 10:
- str = "A" + str; break;
- case 11:
- str = "B" + str; break;
- case 12:
- str = "C" + str; break;
- case 13:
- str = "D" + str; break;
- case 14:
- str = "E" + str; break;
- case 15:
- str = "F" + str; break;
- }
- l = l/16;
- }
- cout << str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement