60分求改 大佬帮帮!!

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

zsj1337455772 @ 2024-12-03 18:11:43

#include<stdio.h>
void find(int a,int b,int c)
{
    int i,h[10000],z=0,j;
    for(i=a;i<b;i++)
    { 
    if((i % 4 == 0 && i % 100 != 0)||(i % 400 == 0))
    {
        h[z]=i;
        z++;
        c++; 
     } 
     }
     printf("%d\n",c); 
     for(j=0;j<=c-1;j++)
     {
        printf("%d ",h[j]);
     }
}
int main()
{
    int a,b,i,sum=0;
    scanf("%d %d",&a,&b);
    find(a,b,sum);
    return 0;
}

by programmer330 @ 2024-12-03 18:20:10

@zsj1337455772

5 行少了等号(这是开区间)

AC求关

#include<stdio.h>
void find(int a,int b,int c)
{
    int i,h[10000],z=0,j;
    for(i=a;i<=b;i++)
    { 
    if((i % 4 == 0 && i % 100 != 0)||(i % 400 == 0))
    {
        h[z]=i;
        z++;
        c++; 
     } 
     }
     printf("%d\n",c); 
     for(j=0;j<=c-1;j++)
     {
        printf("%d ",h[j]);
     }
}
int main()
{
    int a,b,i,sum=0;
    scanf("%d %d",&a,&b);
    find(a,b,sum);
    return 0;
}

by zsj1337455772 @ 2024-12-04 00:16:50

@programmer330谢谢


|