第几天--预处理
来源:互联网 发布:linux date 时间戳 编辑:程序博客网 时间:2024/06/10 00:25
第几天?
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 70901 Accepted Submission(s): 26856
Problem Description
给定一个日期,输出这个日期是该年的第几天。
Input
输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。
Output
对于每组输入数据,输出一行,表示该日期是该年的第几天。
Sample Input
1985/1/202006/3/12
Sample Output
2071
http://acm.hdu.edu.cn/showproblem.php?pid=2005
#include<stdio.h>#define ISYEAP(x) x%4==0&&x%100!=0||x%400==0?1:0int dayOfMonth[][2]={ 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30, 31,31, 31,31, 30,30, 31,31, 30,30, 31,31};struct date{ int day,month,year; void nextDay(){ day++; if(day>dayOfMonth[month][ISYEAP(year)]){ day=1; month++; if(month>12){ month=1; year++; } } } };int buf[3001][13][32];int main(){ //freopen("in.txt","r",stdin); date tmp; tmp.day=1; tmp.month=1; tmp.year=0; int cnt=0; while(tmp.year!=3001){ buf[tmp.year][tmp.month][tmp.day]=cnt; tmp.nextDay(); cnt++; } char s[20]; int y,m,d; while(scanf("%d/%d/%d",&y,&m,&d)!=EOF){ if(m>12||d>31||m<0){ break; } printf("%d\n",buf[y][m][d]-buf[y][1][1]+1); } return 0;}
0 0
- 第几天--预处理
- 第几天
- 【第几天?】
- 第几天?
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天?
- oracle 数据库编码32UTF-8转换ZHS16GBK
- ftk学习记(脚本篇)
- linux常用命令大全
- 使用Flex Bison 和LLVM编写自己的编译器
- Hive 安装
- 第几天--预处理
- IOS 根据日期,获取该日期所在周,月,年的开始日期,结束日期 的方法
- HTML&CSS学习1——画圣诞树
- linux更改文件夹所有者和读写权限
- 剑指offer面试题4
- POI解析excel2007和生成excel2007
- 数据库 存储过程
- MediaPlayer播放器在web项目中调用
- IMPLEMENT_DYNAMIC