Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int chislo, sistema, n;
- int cifri[25];
- cout << "Chislo v osnova 10 = ";
- cin >> chislo;
- cout << "V osnova = ";
- cin >> sistema;
- n = 1;
- while (chislo != 0)
- {
- cout << chislo << " ost. ";
- cifri[n] = chislo % sistema;
- cout << cifri[n] << endl;
- chislo = chislo / sistema;
- n = n + 1;
- }
- // показваме резултата - отзад напред, затова вадим 1
- while (n > 1)
- {
- n = n - 1; // връщаме с 1
- if (cifri[n]<10) cout << cifri[n] << " ";
- // ако е над 10 - цифри A B C ... Z, 65 e кода на A
- else cout << char('A' +cifri[n] - 10) << " ";
- }
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement