typedef struct DATE
{
int year;
int month;
int day;
}DATE;
DATE StanderdDate{2012,1,1};//标准日期
int StanderdDayOfWeek =6;//标准日期是周几 //周日
bool isRuiYear(int year)//判断是否闰年
{
if((year % 400 == 0)|(year % 4 == 0)&(year % 100 != 0))
return true;
else
return false;
}
int SumDays(DATE date)
{
if(date.)
int sum=0;//日期天数差值
int i=0;//循环变量
for(i=0;i
if(isRuiYear(StanderdDate.year+i))//判断是否闰年
sum+=366;
else
sum+=365;
};
int mon[12]={31,28,31,30,31,30,31,31,30,31,30,31};//非闰年
for(i=0;i
sum+=mon[StanderdDate.month+i];
if(i==1)
{
if(isRuiYear(date.year))
sum+=1;//润年+1
}
};
sum+=date.day-StanderdDate.day;//
return (sum+StanderdDayOfWeek)%7;//返回星期几
}
#include"stdio.h"
typedef struct {
int year;
int month;
int day;
}Date;
bool IsLeapYear(int year)
{
if(year%4==0)
{
if(year%100==0)
{
if(year%400==0)
return true;
return false;
}
else
return true;
}
else
return false;
}
int days(Date date)
{
int weekday=7;
for(int year=2012;year
weekday=(weekday+2)%7;
else
weekday=(weekday+1)%7;
for(int month=1;month
weekday=(weekday+3)%7;
else
if(month==4 || month==6 ||month==9 ||month==11 )
weekday=(weekday+2)%7;
else
if(IsLeapYear(year))
weekday=(weekday+1)%7;
for(int day=1;day
weekday=(weekday+day-1)%7;
return weekday;
}
void main()
{
Date date;
scanf("%d%d%d",&date.year,&date.month,&date.day);//依次输入年,月,日
printf("%d",days(date));
}
去网上找