标签:bit mes 大数 name string bsp || begin include
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int main() 5 { 6 string a, b, res; 7 cin >> a >> b; 8 int i, k, inc, lena, lenb, temp; 9 lena = a.length(); lenb = b.length(); 10 for (i = lena - 1, k = lenb - 1, inc = 0; i >= 0 || k >= 0; --i, --k) 11 { 12 temp = inc; 13 if (i >= 0) 14 { 15 temp += a[i] - ‘0‘; 16 } 17 if (k >= 0) 18 { 19 temp += b[k] - ‘0‘; 20 } 21 res += temp % 10 + ‘0‘; 22 inc = temp / 10; 23 } 24 if (inc) 25 { 26 res += inc + ‘0‘; 27 } 28 reverse(begin(res), end(res)); 29 cout << res << endl; 30 return 0; 31 }
标签:bit mes 大数 name string bsp || begin include
原文地址:https://www.cnblogs.com/lj95/p/10336037.html