题目1096:日期差值
来源:互联网 发布:mt4软件使用视频教程 编辑:程序博客网 时间:2024/05/17 13:10
#include <iostream>#include <stdio.h>#include <algorithm>#include <math.h>#include <string>#include <string.h>#include <vector>#include <queue>#include <stack>#include <sstream>#include <climits>#include <cstring>using namespace std;//1096int month[][14]={{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 isRun(int n){ return (n%400==0 || (n%4==0&&n%100!=0))?1:0;}int cnt(int y,int m,int d){ int s=0; for(int i=1;i<y;i++) if(isRun(i)==1) s+=366; else s+=365; int f=isRun(y); for(int i=1;i<m;i++) s+=month[f][i]; s+=d; return s; }int main(){ int y1,y2,m1,m2,d1,d2; //freopen("input.txt","r",stdin); while(scanf("%04d%02d%02d",&y1,&m1,&d1)!=EOF){ scanf("%04d%02d%02d",&y2,&m2,&d2); int ans=cnt(y1,m1,d1)-cnt(y2,m2,d2); if(ans<0) ans=-ans; printf("%d\n",ans+1); } return 0;}/************************************************************** Problem: 1096 User: cust123 Language: C++ Result: Accepted Time:0 ms Memory:1520 kb****************************************************************/
0 0
- 题目1096:日期差值
- 题目1096:日期差值
- 题目1096:日期差值
- 题目1096:日期差值
- 题目1096:日期差值
- 题目1096:日期差值
- 6-题目1096:日期差值
- 九度题目1096:日期差值
- [九度]题目1096:日期差值
- 九度题目1096:日期差值
- 九度OJ 题目1096:日期差值
- 题目1096:日期差值 Java/C++
- 九度-题目1096:日期差值
- 【九度】题目1096:日期差值
- 【九度】题目1096:日期差值
- 九度 oj 题目1096:日期差值
- 九度 OJ 题目1096:日期差值
- 题目6:日期差值
- 黑客与画家摘录
- 主存到Cache直接映射、全相联映射和组相联映射
- Hive调用Java类ReflectUDF
- HOG特征
- 2017华为codecraft 《大视频时代布局》
- 题目1096:日期差值
- Tone mapping进化论
- fopen、fwrite、fread 函数——读写结构体类型数据详解
- Visual Stdio中的断点
- 题目1097:取中值
- Maven 使用profile来区分开发、测试、生产环境
- HTML常用标签使用(二)
- JAVA求学之路第十九天(多线程)
- java -- 异常处理