OJ刷题---1.1.3 Friday the Thirteenth 黑色星期五
来源:互联网 发布:诲女知之乎女的意思 编辑:程序博客网 时间:2024/05/22 12:27
题目要求:
输入代码:
#include<iostream>#include<stdio.h>#include<cstdlib>using namespace std;int month[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31};int ans[8]= {0};int n,end;void work(int n){ int y,m,d,i; int w=1; y=1900; end=y+n-1; m=d=1; while(y!=end||m!=12||d!=31)//到end年12月31日退出循环 { if(d==month[m]+1)//表示到月底,换下一月 { d=1; m++; } if(m==13)//表示到12月份,到下一年 { y++; m=1; } if((y%100!=0&&y%4==0)||y%400==0)//闰年的二月 { month[2]=29; } else { month[2]=28; } if(d==13)//13号 { ans[w]++ ;//13号在该周的次数加1 } w ++ ; w = (w - 1 ) % 7 + 1 ;//表示周几 d ++ ; } cout<<ans[6]<<" "<<ans[7]<<" "; for(i=1; i<=4; i++) { cout<<ans[i]<<" "; } cout<<ans[5]<<endl;}int main(){ //freopen( "friday.in" ," r " ,stdin); //freopen( "friday.out" ," w " ,stdout); cin>>n; work(n); //fclose(stdin);//关闭文件 //fclose(stdout);//关闭文件 return 0;}
运行结果:
0 0
- OJ刷题---1.1.3 Friday the Thirteenth 黑色星期五
- Friday the Thirteenth黑色星期五
- Friday the Thirteenth黑色星期五
- Friday the Thirteenth 黑色星期五
- Usaco 1.1.3 黑色星期五(Friday the Thirteenth)
- ytu 1403: 1.1.3 Friday the Thirteenth 黑色星期五
- 【USACO题库】1.1.3 Friday the Thirteenth黑色星期五
- 【USACO题库】1.1.3 Friday the Thirteenth黑色星期五
- USACO 1.1 黑色星期五Friday the Thirteenth
- Friday the Thirteenth(黑色星期五) USACO
- usaco1.1.3 Friday the Thirteenth黑色星期五
- USACO1.1.3 Friday the Thirteenth(黑色星期五)
- USACO——Friday the Thirteenth 黑色星期五
- (usaco) Friday the Thirteenth 黑色星期五
- luogu1202 [USACO1.1]黑色星期五Friday the Thirteenth
- 洛谷 [USACO1.1]黑色星期五Friday the Thirteenth
- USACO 1.1.3 Friday the Thirteenth (friday)
- 1.1.3 Friday the Thirteenth
- AngularJS ui-router (nested routes)
- C++中引用(&)的用法和应用实例
- 1031. 查验身份证(15)
- crontab命令
- 在Android Studio中如何建立app的assets文件夹
- OJ刷题---1.1.3 Friday the Thirteenth 黑色星期五
- JDBC------dom4j+xml连接Oracle
- Redis集群:redis主从自动切换Sentinel
- 我们国家真的很强
- c/c++可变宏定义
- Universal-Image-Loader图片缓存架构
- 漂亮得不像实力派
- Toast
- stringstream