题解 | #数字颠倒#
数字颠倒
http://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
#include <iostream>
int main()
{
using namespace std;
int number = 0;
int i = 0;
char ch[12]={0};
cin>>number;
if(number==0)
{
cout<<number<<endl;
}
else
{
while(number)
{
ch[i]=number%10+'0';
number=number/10;
i++;
}
ch[i]='\0';
cout<<ch;
}
return 0;
}
int main()
{
using namespace std;
int number = 0;
int i = 0;
char ch[12]={0};
cin>>number;
if(number==0)
{
cout<<number<<endl;
}
else
{
while(number)
{
ch[i]=number%10+'0';
number=number/10;
i++;
}
ch[i]='\0';
cout<<ch;
}
return 0;
}