XZIT20200510102 @ 2020-11-14 19:46:36
#include <stdio.h>
int main()
{
int x,y;
int a[150];
scanf("%d%d",&x,&y);
int i,j=0,k=0;
for(i=x;i<=y;i++){
if(i%4==0&&i%100!=0||i%400==0){
k++;
a[j++]=i;
}
}printf("%d\n",k);
for(i=0;i<k;i++){
printf("%d ",a[i]);
}return 0;
}
C
by Leap_Frog @ 2020-11-14 19:55:31
@小周77 运算优先级,多加括号
by XZIT20200508114 @ 2020-11-20 23:45:41
数组范围定义小了,你用1582-3000这个数据试试,超出了定义范围。
by 0232宋槑 @ 2021-02-10 09:33:21
用函数更好做
by chaoscodes @ 2021-04-27 08:45:42
跟你同样的思路,数组开小了,开个500试试
by YouziChenpi @ 2021-04-27 20:44:18
a[150]小了,我定的是353,还有(i%4==0&&i%100!=0||i%400==0)改成((i%4==0&&i%100!=0)||i%400==0)试试
by CznTree @ 2022-11-09 18:35:00
虽然我是c++ 但是我觉得应该是数组开小了 3001吧