输入两个非负10进制整数A和B(<=230-1),输出A+B的D (1 < D <= 10)进制数。
输入格式:
输入在一行中依次给出3个整数A、B和D。
输出格式:
输出A+B的D进制数。
输入样例:123 456 8输出样例:
1103
题目分析:这是典型的十进制转其他进制
#include <iostream> using namespace std; void test(int m,int k){ if(m/k==0)cout<<m; else{ test(m/k,k); cout<<m%k;} } int main() { int m,n; cin>>n>>m; n=n+m; cin>>m; test(n,m); return 0; }