标签:span pre names reverse ring png 处理 main out
大水题来啦!
不过要注意A B都为零的情况,所以用do-while循环
1 #include<iostream> 2 #include<string> 3 #include<algorithm> 4 5 using namespace std; 6 7 int main() { 8 int a = 0, b = 0; 9 int n = 0; 10 int ary = 0; 11 string d = ""; 12 cin >> a >> b >> ary; 13 n = a + b; 14 do { 15 d += to_string(n % ary); //转化为字符串处理,方便逆序 16 n /= ary; 17 } while (n != 0); 18 reverse(d.begin(), d.end()); //逆序 19 cout << d; 20 return 0; 21 }
贼快
PTA 乙级 1022 D进制的A+B (20分) C++(贼快,调库大法)
标签:span pre names reverse ring png 处理 main out
原文地址:https://www.cnblogs.com/SCP-514/p/13270078.html