各个位相加对10取余。
#include <iostream>
using namespace std;
string st, res;
int main()
{
getline(cin, res);
while (getline(cin, st) && st != "")
{
for (int i = 0; i < st.length(); i++)
res[i] = ((res[i] - '0') + (st[i] - '0'))%10 + '0';
}
cout <<res << endl;
return 0;
}
原文地址:http://blog.csdn.net/wangxinxin_/article/details/46119977