fly123 @ 2017-07-10 08:01:24
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
bool flag=false;
getline(cin,s);
int e;
if(s[0]=='-')cout<<"-";
for(int i=s.size()-1;i>=0;i--){
if(s[i]!=0&&s[i]!='-')flag=true;
e=i;
if(flag)break;
else continue;
}
for(int i=e;i>=0;i--)
{
if(s[i]=='-')break;
cout<<s[i];
}
return 0;
}
by 潘捷 @ 2017-07-10 09:14:24
你都没判断
by Afri_Trigger @ 2017-07-13 15:37:30
你直接翻转为数就可以了,反转后是整数就会自动省去0
#include<cstdio>
int main(void){
int i=0,flag=0;
int n,y=0;
scanf("%d",&n);
if(n<0){
n=n*-1;
flag++;
}
while(n!=0){
y=n%10+y*10;
n=n/10;
}
if(flag==1)printf("-");
printf("%d",y);
return 0;
}