hdu 2005 - 第几天?
题意:判断是否为闰年
解法:这题需要注意一下用scanf能直接读入year,month,day
附上代码:
1: #include<stdlib.h> 2: #include<string.h> 3: #include<stdio.h> 4: #define N 13 5: int month[N]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 6: int main(){ 7: int a,b,c,i; 8: while(scanf("%d/%d/%d",&a,&b,&c)!=EOF){ //这行注意 9: int sum=0; 10: if((a%4==0&&a%100!=0)||(a%400==0)){ 11: month[2]=29; 12: }else{ 13: month[2]=28; 14: } 15: for(i=1;i<b;i++) 16: sum+=month[i]; 17: printf("%d\n",sum+c); 18: } 19: }