题解 | #数字反转#
数字反转
https://www.nowcoder.com/practice/2687c5c174cb4f938bdae01f0a19490c
#include<bits/stdc++.h> using namespace std; int diandao(int c){ if(c/100000!=0) return c%10*100000+c%100/10*10000+c/100000+c%10000/1000*100+c%1000/100*1000+c%10000/1000*10; else if(c/10000!=0) return c%10*10000+c%100/10*1000+c/10000+c%10000/1000*10+c%1000/100*100; else if(c/1000!=0) return c/1000+c%1000/100*10+c%100/10*100+c%10*1000; else if(c/100!=0) return c/100+c%100/10*10+c%10*100; else if(c/10!=0) return c/10+c%10*10; else return c; } int main() { int a=0; while(cin>>a) { int b=0; cin>>b; int c=a+b; if(diandao(a)+diandao(b)==diandao(c)) cout<<c<<endl; else cout<<"NO"<<endl; } return 0; }