萌新求助

P5737 【深基7.例3】闰年展示

ikun_czy @ 2022-11-15 20:57:24

三点过不了


by ikun_czy @ 2022-11-15 20:58:36


using namespace std;int main(void){int n,m,x[355],run=1;
    cin>>n>>m;
    if(n+4>m&&n%4!=0){return 0;}
    else if(n+4>m&&n%4==0){cout<<1<<endl<<n;return 0;}
    else if(n%4==1)n+=3;
    else if(n%4==2)n+=2;
    else if(n%4==3)n+=1;
    while(n<=m){
        if(n%100==0&&n%400!=0)n+=4;
        else
        {
            x[run-1]=n;
            n+=4;
            run++;  
        }
    }
    cout<<run-1<<endl;
    for(int i=0;i<run-1;i++)cout<<x[i]<<' ';
    return 0;}```

by zfj123456 @ 2023-02-08 21:46:42

有可能m<n+4但是m是闰年啊 @czy888


by zfj123456 @ 2023-02-08 21:47:40

而且你第二个判断没有是100倍数的判断@czy888


|