第1个回答 2010-03-23
#include <stdio.h>
#define MONTH_COUNT 13
#define YEAR_DAYS 365
typedef struct _DAY
{
int year;
int month;
int day;
}DAY;
int month[MONTH_COUNT] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int calDays(DAY normDay, DAY Day)
{
int totalDays = 0;
for(int i=normDay.year; i<Day.year; i++)
{
totalDays += YEAR_DAYS;
if(i % 4 ==0 && i % 100 != 0 || i % 400 == 0)
totalDays++;
}
for(i=normDay.month; i<Day.month; i++)
totalDays += month[i];
for(i=normDay.day; i<Day.day; i++)
totalDays++;
return totalDays;
}
void main()
{
DAY inputDate;
DAY normDate = {1, 1, 1};
int duringDays = 0;
static char* wday[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday", "Sunday"};
printf("Please input the date year/month/day :");
scanf("%d %d %d", &(inputDate.year), &(inputDate.month), &(inputDate.day));
duringDays = calDays(normDate, inputDate);
duringDays %= 7;
printf("%s\n", wday[duringDays])
}
哈哈...本回答被提问者采纳
第2个回答 2019-12-26
#include
#define
MONTH_COUNT
13
#define
YEAR_DAYS
365
typedef
struct
_DAY
{
int
year;
int
month;
int
day;
}DAY;
int
month[MONTH_COUNT]
=
{31,
28,
31,
30,
31,
30,
31,
31,
30,
31,
30,
31};
int
calDays(DAY
normDay,
DAY
Day)
{
int
totalDays
=
0;
for(int
i=normDay.year;
i
评论
0
0
加载更多