题解 | 数字反转

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

int reverseInt(int x){
    int ans=0;
    while(x!=0){
        ans*=10;
        ans+=x%10;
        x/=10;
    }
    return ans;
}

int main(){
    int a,b;
    while(cin>>a>>b){
        int c=reverseInt(a+b);
        int z=reverseInt(a)+reverseInt(b);
        if(c==z)cout<<reverseInt(c)<<endl;
        else  cout<<"NO"<<endl;
    }
}

简单reverseInt

全部评论

相关推荐

04-06 16:59
已编辑
河南工业大学 Java
牛牛牛的牛子:最好扔了,实在没有选择的选择
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务