题解 | 数字反转
#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