//Napisati funkciju koja formira zapis datog celog broja u osnovi 2-16. //Resenje kolege Slavka Moconje #include #include #include using namespace std; string pretvori(unsigned, short); main() { unsigned n; cin >> n; cout << pretvori(n, 2) << endl; cout << pretvori(n, 8) << endl; cout << pretvori(n, 16) << endl; return 0; } string pretvori(unsigned n, short o) { string s; int d; for (int i = 0; n; i++) { if ( (d = n%o) <10 ) s += (d + '0'); else s += (d - 10 + 'a'); n = n/o; } reverse(s.begin(), s.end()); return s; }