难度级别:A; 运行时间限制:1000ms; 运行空间限制:51200KB; 代码长度限制:2000000B |
试题描述
|
输入
|
输出
|
输入示例
|
2007-2-3
|
输出示例
|
34
|
//============================================================================
// Name : yearday.cpp
// Author : judyge
// Version : 1.0
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
using namespace std;
int main() {
int index[3];
char time[11];
cin>>time;
int j=0;
for(int i=0;i<11;i++)
{
if(time[i]=='-'||time[i]=='\0')
{
index[j++]=i;
continue;
}
}
int sumy;
int summ;
int sumd;
switch(index[0])
{
case 1:sumy=(time[0]-'0');
case 2:sumy=(time[0]-'0')*10+(time[1]-'0');
case 3:sumy=(time[0]-'0')*100+(time[1]-'0')*10+(time[2]-'0');
case 4:sumy=(time[0]-'0')*1000+(time[1]-'0')*100+(time[2]-'0')*10+(time[3]-'0');
}
if(index[1]-index[0]==2)
{
summ=(time[index[1]-1]-'0');
}
else
if(index[1]-index[0]==3)
{
summ=(time[index[0]+1]-'0')*10+(time[index[1]-1]-'0');
}
if(index[2]-index[1]==2)
{
sumd=(time[index[1]+1]-'0');
}else if(index[2]-index[1]==3)
{
sumd=(time[index[1]+1]-'0')*10+(time[index[2]-1]-'0');
}
int sum=0;
int m[12]={31,28,31,30,31,30,31,31,30,31,30,12};
int n[12]={31,29,31,30,31,30,31,31,30,31,30,12};
if((sumy%4==0&&sumy%100!=0)||sumy%400==0)
{
for(int k=0;k<summ;k++)
{
sum+=n[k];
}
sum+=sumd;
cout<<sum;
}
else
{
for(int k=0;k<summ;k++)
{
sum+=m[k];
}
sum+=sumd;
cout<<sum;
}
return 0;
}