#include "iostream"
#include "string"
#include "sstream"
#include "stdio.h"
#include "algorithm"
using namespace std;
int main()
{
int TestCase;
cin >> TestCase;
while (TestCase--)
{
string num1, num2, ans;
int length;
stringstream temp1, temp2, temp;
int temp3, temp4, sum;
cin >> num1 >> num2;
reverse(num1.begin(), num1.end());//反转函数的使用
reverse(num2.begin(), num2.end());
temp1 << num1;
temp1 >> temp3;
temp2 << num2;
temp2 >> temp4;
sum = temp3 + temp4;
temp << sum;
temp >> ans;
reverse(ans.begin(), ans.end());
length = ans.size();
if (length == 1)
cout << ans << endl;
else
{
int count = 0;
while (ans[count] == '0') count++;//前导0的统计
for (int i = count; i < length; i++)
printf("%c", ans[i]);
cout << endl;
}
}
}
zoj 2001 Adding Reversed Numbers
最新推荐文章于 2022-02-25 21:57:21 发布