题解 | #A+B#

A+B

https://www.nowcoder.com/practice/b183eac8dfba4de99d47c1ca4ce9571f

#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

全部评论

相关推荐

09-17 10:53
四川大学 C++
牛客91242815...:会写标书没有任何卵用,鉴定为横向垃圾导师的受害者
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务