#include <iostream> #include <sstream> #include <string> using namespace std; int my_stoi(string s) { stringstream ss; for (auto iter = s.begin(); iter != s.end(); ++iter) { if (*iter != ',') ss << *iter; } int res = stoi(ss.str()); return res; } int main() { string a_s, b_s; while (cin >> a_s >> b_s) { // 注意 while 处理多个 case int a = my_stoi(a_s), b = my_stoi(b_s); cout << a + b << endl; } } // 64 位输出请用 printf("%lld")
删除逗号在调用stoi