- 数字反转
- 2016-08-23 09:16:27 @
// input code here
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[1000];
int Head=0,Tail,Long,i;
cin>>a;
Long=strlen(a);
Tail=Long;
if(a[0]=='-')
{
cout<<"-";
Head=1;
Long--;
}
i=Tail;
do
{
Tail--;
i--;
}
while(a[i]=='0');
for(i=Tail;i>=Head;i--)
cout<<a[i];
cout<<endl;
return 0;
}
3 条评论
-
贱人在我右边 LV 9 @ 2016-11-18 13:47:11
这才简洁
-
2016-11-18 13:47:01@
#include<iostream>
using namespace std;
int main()
{
int a,b;
b=0;
cin>>a;
while(a!=0){
b=b*10+a%10;
a=a/10;}
cout<<b;
return 0;
} -
2016-11-18 13:46:49@
麻烦死了可
- 1