23 lines
340 B
C++
23 lines
340 B
C++
|
#include <iostream>
|
||
|
using namespace std;
|
||
|
|
||
|
int convert(int number, int base){
|
||
|
if(number == 0 || base == 10){
|
||
|
return number;
|
||
|
}
|
||
|
|
||
|
return (number%base) + 10 * convert(number / base, base);
|
||
|
}
|
||
|
|
||
|
int main(){
|
||
|
int n, base;
|
||
|
cout<<"Number: ";
|
||
|
cin>>n;
|
||
|
cout<<"Target base: ";
|
||
|
cin>>base;
|
||
|
|
||
|
cout<<"Result: "<<convert(n, base)<<endl;
|
||
|
|
||
|
return 0;
|
||
|
}
|