Write a program that converts a natural number in base 10 into the system in any mechanical system of b ( 1 < b≤ 36 ) .
My code isn't working correct.
#include<iostream>
using namespace std;
void doicoso(int n, int c) {
if(n >= c) doicoso(n/c, c);
if(n%c > 9)
cout << static_cast<char>(n%c+55);
else
cout << n%c;
}
main() {
int a,c;
cout << "Nhap so can chuyen: ";
cin >> a;
cout << "Nhap co so: ";
cin >> c;
while(c < 1 || c > 36){
cout << "Co so sai moi ban nhap lai!" << endl;
cin >> c;
}
doicoso(a,c);
}
Edited by hungptit2015, 14 September 2015 - 02:02 AM.