文章
1
粉丝
228
获赞
0
访问
10.4k
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
struct date
{
int y,m,d;
int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
};
bool isleap(int year)
{
return ((year%4==0 && year%100!=0) || (year%400==0));
}
int main()
{
date dd;
int sum;
while(cin>>dd.y>>dd.m>>dd.d)
{
sum=0;
if(dd.m>12 || dd.m<1)
cout<<"Input error!"<<endl;
else if(dd.d<1 || dd.d>dd.mon[dd.m])
cout<<"Input error!"<<endl;
else
{
sum = dd.d;
for(int i=1; i<dd.m; i++)
sum+=dd.mon[i];
if(isleap(dd.y) && dd.m>2)
sum+=1;
cout<<sum<<endl;
}
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发