标签:iostream namespace return name pac sys ios turn col
输入两个非负 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;
int main() {
long a, b, d,sum = 0;
cin >> a >> b >> d;
int t = a + b;
if (t == 0) {
cout << 0;
return 0;
}
int s[100];
int i = 0;
while (t != 0) {
s[i++] = t % d;
t = t / d;
}
for (int j = i - 1; j >= 0; j--)
cout << s[j];
system("pause");
return 0;
}
标签:iostream namespace return name pac sys ios turn col
原文地址:https://www.cnblogs.com/Frances-CY-FKYM/p/12868024.html