标签:include 这一 一点 col 输出 highlight == return cout
输入两个非负 10 进制整数 A 和 B (≤),输出 A+B 的 D (1)进制数。
输入在一行中依次给出 3 个整数 A、B 和 D。
输出 A+B 的 D 进制数。
123 456 8
1103
如果两个数的和是0, 则输出0(这一点比较坑......)需要特判!
#include <iostream> #include <stack> using namespace std; int main() { stack<long long int> s; long long int a, b, n; int d; cin >> a >> b >> d; n = a + b; if(n == 0) cout << "0"; else { while(n != 0) { s.push(n % d); n /= d; } while(!s.empty()) { cout << s.top(); s.pop(); } } return 0; }
标签:include 这一 一点 col 输出 highlight == return cout
原文地址:https://www.cnblogs.com/mjn1/p/10859021.html