如題
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
int k=0,i=0,a[100];
memset(a,0,sizeof(a));
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%d",&a[i]);
if(a[i]%400==0)printf("Case %d: a leap year\n",i+1);
else if(a[i]%100==0)printf("Case %d: a normal year\n",i+1);
else if(a[i]%4==0)printf("Case %d: a leap year\n",i+1);
else printf("Case %d: a normal year\n",i+1);
}
return 0;
}
但小弟把陣列換變數就AC了求大大說明
如題
#include
#include
#include
int main(){
int k=0,i=0,a[100];
memset(a,0,sizeof(a));
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%d",&a[i]);
if(a[i]%400==0)printf("Case %d: a leap year\n",i+1);
else if(a[i]%100==0)printf("Case %d: a normal year\n",i+1);
else if(a[i]%4==0)printf("Case %d: a leap year\n",i+1);
else printf("Case %d: a normal year\n",i+1);
}
return 0;
}
但小弟把陣列換變數就AC了求大大說明
因為測試資料筆數 也就是你的k值 會比你設的100還要多 所以會RE
如題
#include
#include
#include
int main(){
int k=0,i=0,a[100];
memset(a,0,sizeof(a));
scanf("%d",&k);
for(i=0;i<k;i++){
scanf("%d",&a[i]);
if(a[i]%400==0)printf("Case %d: a leap year\n",i+1);
else if(a[i]%100==0)printf("Case %d: a normal year\n",i+1);
else if(a[i]%4==0)printf("Case %d: a leap year\n",i+1);
else printf("Case %d: a normal year\n",i+1);
}
return 0;
}
但小弟把陣列換變數就AC了求大大說明
因為測試資料筆數 也就是你的k值 會比你設的100還要多 所以會RE
原來~謝謝