提交时间:2024-04-10 13:51:33

运行 ID: 142874

# include <iostream> using namespace std ; char i2c ( int x ) { if ( x < 10 ) { return '0' + ( x - 0 ) ; } return 'A' + ( x - 10 ) ; } int main ( ) { int a , b ; cin >> a >> b ; string s ; if ( a == 0 ) { s = "0" ; } while ( a != 0 ) { s = i2c ( a % b ) + s ; a -= a % b ; a /= b ; } cout << s << endl ; return 0 ; }