jokerXYH @ 2022-04-20 22:19:47
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,i=0;
cin>>x;
if(x<0){
x=-x;
cout<<"-";
}
int a[10];
while(x%10==0){
x/=10;
}
while(x!=0){
a[i]=x%10;
x=x/10;
cout<<a[i];
i++;
}
}
by lxc_awa @ 2022-04-22 22:18:31
@jokerXYH 判断一下0不然第一个while死循环了ac代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,i=0;
cin>>x;
if(x==0){
cout<<0;
return 0;
}
if(x<0){
x=-x;
cout<<"-";
}
int a[10];
while(x%10==0){
x/=10;
}
while(x!=0){
a[i]=x%10;
x=x/10;
cout<<a[i];
i++;
}
}