题解 | #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

全部评论

相关推荐

喜欢飞来飞去的雪碧在刷代码:可以试一试字节
点赞 评论 收藏
分享
05-12 17:00
门头沟学院 Java
king122:你的项目描述至少要分点呀,要实习的话,你的描述可以使用什么技术,实现了什么难点,达成了哪些数字指标,这个数字指标尽量是真实的,这样面试应该会多很多,就这样自己包装一下,包装不好可以找我,我有几个大厂最近做过的实习项目也可以包装一下
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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