题解 | A+B(bupt)

A+B

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

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int tostring(string s)
{
    int num=0;
    bool isfu=false;
    if(s[0]=='-')
    {
        isfu=true;
    }
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]>='0'&&s[i]<='9')
        {
            num = num*10+s[i]-'0';
        }
    }
    if(isfu==true)
    {
        num = -num;
    }
    return num;
}
int main() {
    string a, b;
    while (cin >> a >> b) {
        cout << tostring(a)+tostring(b) << endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

AAA专业长城贴瓷砖刘大爷:这样的简历我会直接丢进垃圾桶,花里胡哨的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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