jianguanghuya @ 2024-11-07 21:38:11
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,ans;cin>>s;
if(s[0] == '-')
{
ans = '-';
for(int i = s.size() - 1;i>=1;i--)
{
ans = ans + s[i];
}
}
else
for(int i = s.size() - 1;i>=0;i--)
{
ans = ans + s[i];
}
if(ans[0] == '0')
{
for(int i = 1;i<=ans.size() - 1;i++)
{
cout<<ans[i];
}
}
else if(ans[0] == '-' && ans[1] == '0')
{
cout<<'-';
for(int i = 2;i<=ans.size() - 1;i++)
{
cout<<ans[i];
}
}
else cout<<ans;
return 0;
}
80分,求改