输入两个非负整数,然后每个数字颠倒顺序,如123颠倒之后就是321,反向求和输出。
#include<iostream>
using namespace std;
int inverse(int q)
{
int result=0,k;
while(q)
{
k=q%10;
q=q/10;
result=result*10+k;
}
return result;
}
int main()
{
int i,j;
int m,n;
cout<<"input 2 number:";
cin>>i>>j;
m=inverse(i);
n=inverse(j);
cout<<"the sum of the invertion:"<<m+n;
system("pause");
return 0;
}