输入两个非负整数,然后每个数字颠倒顺序,如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;
}
最后
以上就是斯文秋天最近收集整理的关于输入两个非负整数,然后每个数字颠倒顺序,如123颠倒之后就是321,反向求和输出。的全部内容,更多相关输入两个非负整数内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复