样例一过不了,不知道哪里错了

P1307 [NOIP2011 普及组] 数字反转

embracesmile @ 2024-08-22 17:06:37


#include<iostream>
int a[100];
using namespace std;
int main()
{
    int n,s=0,b,c;
    cin>>n;
    if(n<0)
    {
        cout<<"-";
        b=0-n;
    }
    else
    b=n;
    while(b!=0)
    {
        s++;
        a[s]=b%10;
        b=b/10;
    }
    for(int i=1;i<=s;i++)
    {
        if(a[i]!=0)
        {
            c=i;
            break;
        }
    }
    for(int i=c;i<=s;i++)
    {
        cout<<a[i];
    }
}

by dream_dad @ 2024-08-22 17:10:18

@embracesmile 0要特判


by Z_nj @ 2024-08-22 17:11:22

特判一下0


by dream_dad @ 2024-08-22 17:12:05

我一开始也是?


by Emil_ @ 2024-08-22 17:14:15

@Z_nj 666


by Z_nj @ 2024-08-22 17:15:13

@Emil_ biejiao


by Emil_ @ 2024-08-22 17:15:44

@Z_nj rj


by embracesmile @ 2024-08-22 17:17:48

@dream_dad 噢噢 谢谢,但是为什么我这个代码运行的时候输入零,得到的结果就是零呢


by dream_dad @ 2024-08-22 17:20:57

是0(00


by Are_you_sure_yxy @ 2024-08-23 20:24:15

还要判断以下0(求关)


|