Problem Description
写一个函数,给定年、月、日,计算该日期是该年的第几天。在主函数中输入一个日期(含年、月、日),通过函数调用,得到该日期所对应这一年的第几天,并输出该数值。
Input Description
三个以空格分隔的整数,分别表示该日期的年、月、日。
Output Description
输入日期所对应这一年的第几天,一个整数,单独占一行。
Sample Input
2014 3 8
Sample Output
67
Hint
可以采用如下函数原型
int getDays(int year, int month, int day);
计算过程中注意闰年。
#include <stdio.h>
// 定义一个函数,判断一个年份是否是闰年,返回1或0
int is_leap(int year) {
// 如果能被4整除,且不能被100整除,或者能被400整除,是闰年
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
return 1;
}
// 否则ÿ