__HappY__ @ 2023-07-05 15:41:07
#include<bits/stdc++.h>
using namespace std;
bool rn(int n)
{
if(n%4!=0&&n%400!=0||n%100==0)
{
return 0;
}
else return 1;
}
int main()
{
int x,y;
cin>>x>>y;
int i=0;
for(;x<=y;x++)
{
if(rn(x)==1)
{
i++;
}
}
cout<<i<<endl;
for(;x<=y;x++)
{
if(rn(x==1))
{
cout<<x<<' '
}
}
return 0;
}
by Tjaweiof @ 2023-07-05 15:50:41
rn
函数因改为
bool rn(int n)
{
if(n%4!=0||(n%100==0&&n%400!=0)){
return 0;
}
else return 1;
}
by Tjaweiof @ 2023-07-05 15:50:52
@hanyi741
by __HappY__ @ 2023-07-05 15:58:22
@Tjaweiof 还是只过了一个
by Tjaweiof @ 2023-07-05 16:04:53
算了,你这样有点难搞,我认为我这样比较容易
bool rn(int n){
if(n%4==0&&n%100!=0&&n%400==0){
return 1;
}
else return 0;
}
by Tjaweiof @ 2023-07-05 16:05:02
@hanyi741
by chenluohan @ 2023-07-05 16:10:34
@hanyi741 rn函数应改为
bool rn(int n) {
if (n % 4 == 0 && n % 100 != 0 || n % 400 == 0) {
return 1;
} else return 0;
}
by zqh123b @ 2023-07-05 16:20:18
@hanyi741
bool rn(int y){
if(y%4==0){
if(y%100==0){
if(y%400==0) return 1;
else return 0;
}
else return 1;
}
else return 0;
}
这个比较长,但是更好理解。
by 编码落寞 @ 2023-07-05 16:29:12
if(rn(x==1))
没看懂x==1的作用。
而且第二个for循环里面的x的初值已经变了
by blue_gandi_ @ 2023-07-13 19:42:49
一大堆错误