usaco1.1.3 Friday the Thirteenth黑色星期五
2012-01-10 21:39
369 查看
usaco1.1.3
Friday the Thirteenth黑色星期五
题目翻译:http://www.nocow.cn/index.php/Translate:USACO/friday
很简单的模拟题,关键是读清楚题,注意如何判断闰年。
Friday the Thirteenth黑色星期五
题目翻译:http://www.nocow.cn/index.php/Translate:USACO/friday
很简单的模拟题,关键是读清楚题,注意如何判断闰年。
/* ID: wsc5001 LANG: C TASK: friday */ #include<stdio.h> int runnian(int y) { if (y%100==0) { if (y%400==0) return 1; else return 0; } if (y%4==0) return 1; } int xingqi(int yu) { switch (yu) { case 0:return 6; case 1:return 7; default:return yu-1; } } int main() { FILE *fin,*fout; fin=fopen("friday.in","r"); fout=fopen("friday.out","w"); int i,j,n,runyear,tongji[8]={0},dayone=1,t; fscanf(fin,"%d",&n); for(i=0;i<n;i++) { runyear=runnian(1900+i); for(j=1;j<=12;j++) { t=xingqi((dayone+13)%7); tongji[t]+=1; if(j==2)//二月 { if (runyear==1) dayone=xingqi(dayone+29+1); //闰年 else dayone=xingqi(dayone+28+1); } else if(j==4||j==6||j==9||j==11)//小月 dayone=xingqi(dayone+30+1); else//大月 dayone=xingqi(dayone+31+1); } } fprintf(fout,"%d %d %d %d %d %d %d\n",tongji[6],tongji[7],tongji[1],tongji[2],tongji[3],tongji[4],tongji[5]); //printf("%d %d %d %d %d %d %d\n",tongji[6],tongji[7],tongji[1],tongji[2],tongji[3],tongji[4],tongji[5]); fclose(fin); fclose(fout); //getchar(); }
相关文章推荐
- 【USACO题库】1.1.3 Friday the Thirteenth黑色星期五
- USACO1.1.3--Friday the Thirteenth
- [USACO 1.1.3] Friday the Thirteenth
- USACO 1.1.3 - Friday the Thirteenth(模拟)
- USACO之Section1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth 13日星期五
- USACO1.1.3 Friday the Thirteenth(黑色星期五)
- USACO 1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth
- Usaco 1.1.3 黑色星期五(Friday the Thirteenth)
- USACO1.1.3 Friday the Thirteenth (friday)
- USACO1.1.3 Friday the Thirteenth (friday)
- USACO 1.1.3 Friday the Thirteenth (friday)
- USACO 1.1.3 Friday the Thirteenth
- USACO1.1.3[Friday The Thirteenth]
- USACO1.1.3 - Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth
- USACO1.1.3 Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth