-
描述
-
给定一个整数,请将该数各个位上数字反转得到一个新数。新数也应满足整数的常见形
式,即除非给定的原数为零,否则反转后得到的新数的最高位数字不应为零
输入
- 输入共 1 行,一个整数N。 输出
- 输出共 1 行,一个整数,表示反转后的新数。 样例输入
-
123
样例输出
-
321
#include<bits/stdc++.h>
using namespace std;
int ji(int n)
{
int s=0;
while (n!=0)
{
s=s*10+n%10;
n=n/10;
}
return s;
}
int main()
{
int m,t;
cin>>m;
if(m==0)
cout<<"0";
else
cout<<ji(m)<<endl;
return 0;
}