Snake_e @ 2018-08-23 13:50:54
#include<iostream>
#include<cstring>
using namespace std;
string c1,b1;
int a[1000000];
int main()
{
int l,le,k;
cin>>c1;
if(c1[0]=='-')
{
cout<<"-";
}
l=c1.length();
for(int i=l-1;i>=0;i--)
{
a[i]=c1[l-1-i]-'0';
}
le=l;
while(a[le]==0)
{
le--;
}
for(int i=0;i<=le-1;i++)
{
cout<<a[i];
}
}
by Lhc_fl @ 2018-08-23 13:55:57
最后一个花括号为什么不对齐啊。。。
by yangruiping @ 2018-08-23 14:11:48
#include <iostream>
using namespace std;
int main(){
char f;
int n,t,d,nf=0,u;
cin>>n;
if(n<0){
f='-';
t=0-n;
cout<<f;
}else{
t=n;
}
if(n<10&&n>-10){
cout<<n;
}else{
for(;t>0;){
u=t%10;
if(u!=0||nf!=0){
cout<<u;
nf=1;
}
t=t/10;
}
}
return 0;
}
by yangruiping @ 2018-08-23 14:12:09
AC码
by yangruiping @ 2018-08-23 14:17:50
@Snake_e
by Billy●Herrington @ 2018-09-08 10:46:41
#include <iostream>
using namespace std;
int ans;
int main()
{
int n;
cin >> n;
while(n)
{
ans=ans*10+n%10;
n/=10;
}
cout << ans;
return 0;
}