我的参考代码:
```cpp
#include<bits/stdc++.h>
using namespace std;
int f(int a){
int b=0;
while(a){
b=b*10+a%10;
a/=10;
}
return b;
}
int main(){
int ans=0;
cin>>ans;
cout<<f(ans);
return 0;
}
```
by M3te0rDream @ 2024-01-06 14:48:02
可以采用字符串来实现:
```cpp
#include<bits/stdc++.h>
using namespace std;
string s;
bool f;
int main()
{
cin>>s;
if (s=="0") {cout<<0; return 0;}
if (s[0]=='-') cout<<'-';
reverse(s.begin(),s.end());
for (int i=0;i<s.length();i++)
{
if (s[i]=='0'&&!f) continue;
f=1;
if (s[i]!='-') cout<<s[i];
}
return 0;
}
```
by PubeLLN @ 2024-01-06 15:04:53
@[xXMeteorDreamXx](/user/927843)
@[PubeLLN](/user/820947)
我还只是个小学生,不会啊
by ZiruiLIU @ 2024-01-13 13:20:32
@[ZiruiLIU](/user/1128297) 那么简单不会吗
by M3te0rDream @ 2024-01-13 18:23:40