poj2080--算日期
来源:互联网 发布:系统之家数据恢复 编辑:程序博客网 时间:2024/06/05 00:09
题意:起始日期为2001-1-1,求过了那天后的日期还有那天是周几。
思路:最重要的是判断闰年,加一个判断函数,之后周几对7取余数就知道了。
#include <iostream>using namespace std; int mon[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31,0,31,29,31,30,31,30,31,31,30,31,30,31};int yea[2]={365,366};int n;char zhou[7][15]={"Saturday","Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday"};/* run this program using the console pauser or add your own getch, system("pause") or input loop */int judge(int y){if((y%400==0)||(y%4==0&&y%100!=0))return 1;else return 0;}int main(int argc, char** argv) {while(cin>>n&&n!=-1){int i,j,day=1;int ff=n%7;for(i=2000;n>=yea[judge(i)];i++)n-=yea[judge(i)];int tt=judge(i);for(j=1;n>=mon[tt][j];j++)n-=mon[tt][j];day+=n;printf("%d-%02d-%02d %s\n",i,j,day,zhou[ff]);} return 0;}
阅读全文
1 0
- poj2080--算日期
- poj2080(日期处理问题)
- poj2080
- POJ2080
- poj2080
- poj2080
- poj2080
- POJ2080 日期计算(1),模拟题,因为细节WA很久
- POJ2080-Calendar
- POJ2080-Calendar
- poj2080 日历
- poj2080!【水题】
- poj2080 Calendar
- poj2080 Calendar
- POJ2080日历问题
- POJ2080解题报告
- POJ2080简单模拟
- POJ2080--Calendar以及一个类似的编程面试题
- C++程序员学Java系列之三十:数据结构之向量Vector
- HDU--dp练习--1004--Max sum
- Leetcode刷题day2
- 阿里 HotFix 热更新 集成
- 自己动手编写FreeBSD内核防火墙模块
- poj2080--算日期
- Java集合类
- 生成标签的工具
- angular-cli
- 线索二叉树的生成及遍历
- 垂直居中
- poi,jxl读取excel文件
- QML程序架构设计(一)
- 使用 IDEA + Maven + Git 快速开发 Web 应用