c语言判断给定日期是当年的第几天
1 #include <stdio.h> 2 int main(int argc, char *argv[]) 3 { 4 printf("%d\n",day(2009,3,6)); 5 return 0; 6 } 7 8 int day(int y,int m,int d){ 9 int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 10 if((y%4==0 && y%100 != 0) || (y%400 == 0)) month[2]=29; 11 int sum=0,i; 12 for(i=1;i<m;i++){ 13 sum=sum+month[i]; 14 } 15 return (sum+d); 16 }