模拟大数相加
注意最后要判断进位
class Solution {public:string addStrings(string num1, string num2) {string res = "";int i = num1.length()-1, j = num2.length()-1;int cnt = 0;while(i >=0 || j >= 0){if(i >= 0 && j >= 0){int a = num1[i]-'0', b = num2[j]-'0';res += (a + b + cnt)%10 + '0';cnt = (a + b + cnt)/10;i--;j--;}else if(i >= 0){int x = num1[i] - '0';res += (x + cnt)%10 + '0';cnt = (cnt + x)/10;i--;}else if(j >= 0){int y = num2[j]-'0';res += (y + cnt)%10 + '0';cnt = (cnt + y)/10;j--;}}if(cnt > 0) res += cnt+'0';reverse(res.begin(), res.end());return res;}};
