题解 | #数字反转#

数字反转

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

#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    string a, b;
    while (cin >> a >> b) {
        int num1=atoi(a.c_str())+atoi(b.c_str());
        reverse(a.begin(),a.end());
        reverse(b.begin(),b.end());
        int num2=atoi(a.c_str())+atoi(b.c_str());
        string str1=to_string(num1);
        string str2=to_string(num2);
        reverse(str2.begin(),str2.end());
        if(str1==str2)
        {
            cout<<num1<<endl;
        }
        else {
            cout<<"NO"<<endl;
        }      
    }
    return 0;
}

全部评论

相关推荐

鬼迹人途:你去投一投尚游游戏,服务器一面,第一个图算法,做完了给你一个策略题,你给出方案他就提出低概率问题,答不上当场给你挂
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务