这一个题目着实考察程序员的其他能力,时间方面我的能力真的很差,总是能把日期记错,把时间弄反,庆幸的是,我还是会看闹钟的,也不知道现在还有没有不会看的人,哈哈。
代码实现如下:
LANG: C
ID: logoo2
PROG: friday
/
#include <stdio.h>
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int now = 6;
int ans[7];
int isry(int year)
{
return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));
}
int main(void)
{
int n;
int i, j;
freopen("friday.in", "r", stdin);
freopen("friday.out", "w", stdout);
scanf("%d", &n);
n += 1900 – 1;
for(i = 1900; i <= n; i++){
if(isry(i)){
day[1] = 29;
}
for(j = 0; j < 12; j++){
ans[now]++;
now = (now + day[j]) % 7;
}
day[1] = 28;
}
printf("%d", ans[6]);
for(i = 0; i < 6; i++){
printf(" %d", ans[i]);
}
printf("\n");
return 0;
}