QLUzongyuxing @ 2022-01-13 21:04:32
using namespace std;
int main()
{
string s;
cin>>s;
if(s[0]=='-'){
cout<<s[0];
}
for(int i=s.size() -1;i>=0;i--){
if(s[i]!='0'&&s[i]!='-'){
cout<<s[i];
}
}
}
by Jr_Zlw @ 2022-01-13 21:12:02
hack: -3080
by 3a51_ @ 2022-01-13 21:33:43
@QLUzongyuxing 建议拆开每一位。
#include<iostream>
using namespace std;
int main()
{
int n,ans=0;
cin>>n;
while(n!=0)
{
ans=ans*10+n%10;
n/=10;
}
cout<<ans;
return 0;
}
by 3a51_ @ 2022-01-13 21:34:13
如果0在中间就会处理错。
by QLUzongyuxing @ 2022-01-14 09:51:37
@Tothetime_tolife 欧克了,谢谢