are_trying_coding @ 2021-11-29 21:09:21
#include<bits/stdc++.h>
using namespace std;
int main()
{
long int x,i;
cin>>x;
if(x<0){cout<<'-';x=-x;}
if(x==0) cout<<0;
i=x%10;
if(i!=0) cout<<i;
x=x/10;
while(x)
{
i=x%10;
cout<<i;
x=x/10;
}
return 0;
}
by HarunluoON @ 2021-11-29 21:11:57
输入的末尾可能有很多个0
所以if(i!=0)
应该改成while(i==0)
试试?
by _ROSE_ @ 2021-11-29 21:18:35
不用特判就可以过吧,
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
scanf("%d",&n);
int k=n,y=0;
while(k){
y=y*10+k%10;
k/=10;
}
printf("%d",y);
return 0;
}
by 19x31 @ 2021-12-23 11:10:38
#include<bits/stdc++.h>
using namespace std;
int main()
{
int m,t=0;
cin>>m;
while(m!=0){
t*=10;t+=m%10;m/=10;
}
cout<<t;
return 0;
}
不用特判也可以通过