PCLP2/lab07/02.cpp
Fándly Gergő 4a6331088a chore: Lab07
2020-05-01 17:58:05 +03:00

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;
}