An problem about date 根据年月日计算 星期几
2016-05-02 16:34
302 查看
/W = (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7(1、2月需要看作上一年的13、14月)
#include<stdio.h> #include<string.h> #include<math.h> #include<iostream> #include<algorithm> #include<queue> #include<vector> #include<set> #include<stack> #include<string> #include<sstream> #include<map> #include<cctype> #include<limits.h> using namespace std; int main() { int y, m, d, w; while(scanf("%d%d%d",&y,&m,&d)!=EOF) { if(m < 3) { m += 12; --y; } w =(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400+1)%7; printf("%d\n",w); } return 0; }
相关文章推荐
- 【原生态跨平台:ASP.NET Core 1.0(非Mono)在 Ubuntu 14.04 服务器上一对一的配置实现-篇幅2】
- TextView实现跑马灯/两个跑马灯效果
- VMWARE 12安装Tools
- RandomAccessFile类
- 浙大 PTA 5-39 魔法优惠券 (25分)
- spring boot 异常处理
- [从头学声学] 第202节 复合的声波(1)
- Swift Swift和OC混编
- 华为Java编程规范
- scanf的使用注意
- OpenCV—基本矩阵操作与示例
- 使用angularjs和bootstrap写一个简单的购物车
- 查看linux已安装jdk
- Python yield and iterables
- 常用的格式控制符
- linux优先级、性能监控指令
- 【福州大学第十三届程序设计竞赛_重现】D - 炉石传说(二分图最大匹配)
- AngularJS(二)——AngularJS主要内容
- parquet性能测试
- 数据结构进阶(二)矩阵(稀疏矩阵)的压缩存储