地址:http://hustoj.sinaapp.com/problem.php?id=1818
又是水题,枚举每天的情况
1 #include <stdio.h> 2 3 int month[12]={31,28,31,30,31,30,31,31,30,31,30,31},week[7]; 4 int count,n; 5 6 int main() 7 { 8 int i=0,j=0,k=0; 9 scanf("%d",&n); 10 count=1;//天数计数 11 for(i=1900;i<1900+n;i++) 12 { 13 if ((((i%4)==0)&&((i%100)!=0))||((i%400)==0)) month[1]=29; 14 else month[1]=28; 15 count=count%7; 16 for(j=1;j<=12;j++) 17 { 18 for(k=1;k<=month[j-1];k++) 19 { 20 if(13==k) week[count%7]++; 21 count++; 22 } 23 } 24 } 25 printf("%d ",week[6]); 26 for(i=0;i<6;i++) 27 { 28 printf("%d",week[i]); 29 if(i!=5) printf(" ");//要不然格式错。。。 30 } 31 printf("\n"); 32 return 0; 33 }