20分求助

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

bjqxszx_zhongqide @ 2024-02-17 09:24:20

#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,n=0;
    cin>>x>>y;
    int a[3001];
    for(int i=x;i<=y-x+1;i++){
        if(((i%4==0)&&(i%100!=0))||(i%400==0){
            n++;
            a[n]=i;
        }
    }
    cout<<n<<endl;
    for(int i=1;i<=n;i++){
        cout<<a[i]<<" ";
    }
    return 0;
}

by zhouyiran_2011 @ 2024-02-17 09:46:05

循环那里,应该是从xy @bjqxszx_zhongqide


by bjqxszx_zhongqide @ 2024-02-17 10:27:52

@zhouyiran_2011 AC了谢谢


|