LikeAC @ 2020-09-19 18:58:21
错误点信息:
Wrong Answer. wrong answer On line 1 column 1, read 0, expected 9.
但是…………
测试数据输入:900000000
输出:9
#include<bits/stdc++.h>
using namespace std;
string s;
int len;
int main()
{
cin>>s;
len=s.length();
if(s[0]=='-')
{
cout<<'-';
while(s[len-1]=='0'&&len>2)len--;
for(int i=len-1;i>=1;i--)
{
cout<<s[i];
}
}
else
{
while(s[len-1]=='0'&&len>2)len--;
for(int i=len-1;i>=0;i--)
{
cout<<s[i];
}
}
return 0;
}
by LucasXu80 @ 2020-09-19 19:02:39
@LikeAC 您的代码输出的是 09
。
by LikeAC @ 2020-09-19 19:22:53
哦,不好意思,我忘记在本机上试一试了
by LikeAC @ 2020-09-19 19:23:23
谢谢大佬
by liuzimingc @ 2020-11-01 20:28:06
@LikeAC
#include<cstdio>
#include<cmath>
int main(){
int a,i=1,as,ans,bure;
scanf("%d",&a);
if (a<0)
printf("-");
a=abs(a);
bure=0;
if (a%10!=0 || bure==1)
{
printf("%d",a%10);
bure=1;
}
while (a/10>=1)
{
a=a/10;
if (a%10!=0 || bure==1)
{
printf("%d",a%10);
bure=1;
}
}
return 0;
}