SYX2022 @ 2023-05-11 16:38:17
#include<bits/stdc++.h>
using namespace std;
bool rn(int s)
{
if(s%4==0||s%100==0||s%400==0)
return true;
else return false;
}
int main()
{
int x,y,i,a[1150],j=1;
cin>>x>>y;
for(i=x;i<=y;i++)
{
if(rn(i))
{
a[j]=i;
j++;
}
}
cout<<j<<endl;
for(i=1;i<=j;i++)
cout<<a[i]<<' ';
return 0;
}
我用的是函数,求帮忙检查问题
by AlicX @ 2023-05-11 16:58:23
by SYX2022 @ 2023-05-11 16:59:12
emm……
我早就过了
by Kedit2007 @ 2023-05-11 16:59:20
闰年判断规则应该是:
if ((s % 4 == 0 && s % 100 != 0) || s % 400 == 0)
注意