题解 | #数字反转#

数字反转

https://www.nowcoder.com/practice/2687c5c174cb4f938bdae01f0a19490c

#include <bits/stdc++.h>
using namespace std;

string f(int a, int b){
    int sum = a+b;
    string temp = to_string(sum);
    string s1 = to_string(a);
    string s2 = to_string(b);
    reverse(temp.begin(),temp.end());
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    return stoi(temp) == stoi(s1)+stoi(s2)?to_string(sum):"NO";
}

int main() {
    int a, b;
    while (cin >> a >> b) { // 注意 while 处理多个 case
        cout<<f(a,b)<<endl;
    }
}
// 64 位输出请用 printf("%lld")

qd

全部评论

相关推荐

故事和酒66:假设一下,就算报了培训班,不还是要投简历,只是项目改了。那不如先写几个培训班的项目,纯靠编,然后试试有没有面试。如果真有再报也不迟,如果没有还是没有,那就不是培训班的问题了。
点赞 评论 收藏
分享
我的代码出BUG了:@美团@腾讯@字节跳动@阿里巴巴。你们好好看看吧,你们就挂我吧,到时候被人家鸽穿还得录取我
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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