杭电 HDU 1205 第几天?

第几天?Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 90226Accepted Submission(s): 33949

Problem Description

给定一个日期,,输出这个日期是该年的第几天。

Input

输入数据有多组,每组占一行,数据格式为YYYY/MM/DD组成,具体参见sample input ,另外,可以向你确保所有的输入数据是合法的。

Output

对于每组输入数据,输出一行,表示该日期是该年的第几天。

Sample Input

1985/1/202006/3/12

Sample Output

2071

Author

lcy

上学期 觉得好难好难 但是 今天来说 水的不行啊 唉

#include<iostream>using namespace std;bool leapyear(int n){if(n%4==0&&n%100!=0||n%400==0)return 1;elsereturn 0;}int main(){int year,mouth,day;char ch1,ch2;while(cin>>year>>ch1>>mouth>>ch2>>day){int sum=0;for(int k=1;k<mouth;k++){if(k==1||k==3||k==5||k==7||k==8||k==10||k==12)sum+=31;else if(k==2){if(leapyear(year))sum+=29;elsesum+=28;}elsesum+=30;}sum+=day;cout<<sum<<endl;}return 0;}

一直想去旅行,去很美很美的地方,但往往真正踏足想去的地方,

杭电 HDU 1205 第几天?

相关文章:

你感兴趣的文章:

标签云: