直接上代码!!!! Accepted!!!
#include <stdio.h>
#include <stdlib.h>
/* 日期的结构体 */
typedef struct date{
int year;
int month;
int day;
}Date;
/* 记录非闰年当前月之前的总天数 */
int daysMonth[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
/*记录一周*/
char week[7][10] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
/* 计算是不是闰年,闰年2月份是29天,总天数是366 */
int isLeapYear(const int year)
{
return ( (year%4 == 0)&&(year%100 != 0) || (year%400 == 0) );
}
/* 计算某个日期在一年中是第几天 */
int daysInYear(Date *date)
{
int days = daysMonth[date->month - 1] + date->day;
if(isLeapYear(date->year) && (date->month >=3))
days++;
return days;
}
/*
比较那个日期大 date1 > date2 ? 1: 0
*/