aniuge @ 2017-05-02 10:33:50
#include<iostream>
using namespace std;
#include<cstring>
#include <string>
int main()
{
char s[1000];
cin.getline(s,1000);
int len=strlen(s),i,j;
if(s[0]=='-')
{
for(i=len-1;i>=1;i--)
{
if(s[i]=='0') continue;
else break;
}
if(i==1) {cout<<"0"<<endl;}
else
{
cout<<'-';
for(j=i;j>=1;j--)
{
cout<<s[j];
}
cout<<endl;
}
}
else
{
for(i=len-1;i>=0;i--)
{
if(s[i]=='0') continue;
else break;
}
if(i==0) {cout<<"0"<<endl;}
else
for(j=i;j>=0;j--)
cout<<s[j];
cout<<endl;
}
return 0;
}
by 孔大 @ 2017-05-02 13:05:45
不知道
by hehehemc @ 2017-05-03 16:46:52
数字反转
#include<iostream>
using namespace std;
int main()
{
int n,a=0;
int i,j=0;
cin>>n;
if(n<0)
{
j=1;
n=-n;
}
while(n>0)
{
a=a*10+n%10;
n=n/10;
}
if(j==1)
a=-a;
cout<<a;
return 0;
}