C题解 1022 D进制的A+B (20 分)
原题
https://pintia.cn/problem-sets/994805260223102976/problems/994805299301433344
代码
#include
#include
using namespace std;
// char result[32];
vector vec;
int main()
{
// string str="";
long A,B;
int D;
cin >> A >> B >> D;
long sub=A+B;
/*while (sub>0) 没有考虑到A B都为0的情况下
{
vec.push_back(sub%D);
sub=sub/D;
}*/
do
{
vec.push_back(sub%D);
sub=sub/D;
} while (sub>0);
for (int i = vec.size()-1; i >=0; i--)
{
cout << vec[i];
}
return 0;
}