```cpp
#include<iostream>
using namespace std;
int a[3000]={};
int is_leap(int n){
if(n%100 != 0){
if(n%4==0){
return 1;
}else{
return 0;
}
}else{
if(n%400==0){
return 1;
}else{
return 0;
}
}
}
int main(){
int x,y,cnt=0;
cin>>x>>y;
for(int i=x;i<=y;i++){ //x和y都包括
if(is_leap(i)){
a[cnt++]=i; //你这个不是赋值
}
}
cout<<cnt<<endl;//你凑的样例吧
for(int i=0;i<cnt;i++){
cout<<a[i]<<" ";
}
return 0;
}
```
求关
by qwq2011 @ 2024-03-10 15:38:32
@[majingwu2013](/user/959418)
by qwq2011 @ 2024-03-10 15:38:43
a[cnt++]==i; 这句错的,用=
by xiao_qiu @ 2024-03-10 15:45:30
@[majingwu2013](/user/959418)
或这样写:```c
#include<bits/stdc++.h>
using namespace std;
int x,y,c[2000],d=0;
int p(int n)
{
if(n%400==0)
{
return 1;
}
if(n%4==0&&n%100!=0)
{
return 1;
}
return 0;
}
int main()
{
scanf("%d%d",&x,&y);
if(x>y)
{
swap(x,y);
}
for(int i=x;i<=y;i++)
{
if(p(i))
{
c[++d]=i;
}
}
printf("%d\n",d);
for(int i=1;i<=d;i++)
{
printf("%d ",c[i]);
}
return 0;
}
```
by yfzy18723122277 @ 2024-07-15 20:56:26