/输入年月日,计算该天是本年的第N天(1<=年<=3000,1<=月<=12,1<=日<=31),如输入数据为2017 12 24三个参数,输出结果为“N=358”
/
#include<iostream>
using namespace std;
const int months[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int is_leap(int year){
if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
return 1;
return 0;
}
int get_days(int y,int m){
if(m==2) return months[m]+is_leap(y);
return months[m];
}
int calculateDayOfYear(int y,int m,int d){
int n = 0;
for(int i=1;i<m;i++)
n+=get_days(y,i);
for(int i=1;i<=d;i++)
n++;
return n;
}
int main(){
int y,m,d;
cin>>y>>m>>d;
printf("N=%d",calculateDayOfYear(y,m,d));
return 0;
}