liaochenzhe0422 @ 2024-05-27 17:21:33
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,i;
string b,c;
cin>>b;
c=b;
a=b.length();
reverse(b.begin(),b.end());
if(c[0]!='-')
{
for(i=0;i<b.length();i++)
{
if(a!=0)
{
if(b[i]!='0')cout<<b[i];
else a--;
}
else cout<<'0';
}
}
else
{
a--;
cout<<"-";
for(i=0;i<b.length();i++)
{
if(a!=0)
{
if(b[i]!='-')
{
if(b[i]!='0')cout<<b[i];
else a--;
}
}
else cout<<0;
}
}
}
by renzhanwen @ 2024-05-27 18:29:14
如果输入的数是0呢?
好像没有考虑到!