第几天
来源:互联网 发布:qq农场刷级软件 编辑:程序博客网 时间:2024/05/17 00:06
1915: 第几天
Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 517 Solved: 302
[Submit][Status][Web Board]
Description
给定一个日期,输出这个日期是该年的第几天。
Input
输入数据有多组,每组占一行,数据格式为YYYY-MM-DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。
Output
对于每组输入数据,输出一行,表示该日期是该年的第几天。
Sample Input
2000-01-01
Sample Output
1
#include <iostream>
using
namespace
std;
int
main()
{
int
sum_day(
int
,
int
);
int
leap(
int
year);
int
year,month,day,days;
char
c=196;
cin>>year>>c>>month>>c>>day;
days=sum_day(month,day);
if
(leap(year)&&month>=3)
days=days+1;
cout<<days<<endl;
return
0;
}
int
sum_day(
int
month,
int
day)
{
int
a,b;
switch
(month)
{
case
1:a=31;
break
;
case
2:a=28;
break
;
case
3:a=31;
break
;
case
4:a=30;
break
;
case
5:a=31;
break
;
case
6:a=30;
break
;
case
7:a=31;
break
;
case
8:a=31;
break
;
case
9:a=30;
break
;
case
10:a=31;
break
;
case
11:a=30;
break
;
case
12:a=31;
break
;
}
for
(b=0;b<month-1;b++)
day=day+a;
return
(day);
}
int
leap(
int
year)
{
int
leap;
leap=year%4==0&&year%100!=0||year%400==0;
return
(leap);
}
0 0
- 第几天
- 【第几天?】
- 第几天?
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天
- 第几天?
- 第几天
- 第几天
- 第几天?
- 第几天?
- 第几天
- OCP 1Z0 051 151
- vim打开文档出现的^M是什么
- sqli-labs ---- Less-2
- 访问谷歌时下载超时问题 dl.google.com、developers.google.com
- Android SDK 更新和下载慢怎么办?
- 第几天
- 树莓派的上手教程
- centos 6.3用yum安装中文输入法
- SDN上摘抄的印度人写的RSDDSTAT*等表的用途
- 临近iOS 8发布 iOS 7升级率仍在继续攀升
- centos in虚拟机Vmware 在win7 系统下无法联网的解决方法
- Excuses, Excuses! - UVa 409 哈希字符串
- 第五天 RAID
- 5月31日互联网理财产品收益播报:余额宝再跌