蔡勒公式
作者:
Sundae
,
2020-02-26 12:27:22
,
所有人可见
,
阅读 891
#include<stdio.h>
//蔡勒公式
int Change(int year, int month, int day)//根据日期判断出星期几
{
if(month == 1 || month == 2){
month += 12;
year--;
}
int c = year / 100;
int y = year % 100;
int m = month;
int d = day;
int W = c / 4 - 2 * c + y + y / 4 + 26 * (m + 1) / 10 + d - 1;
if(W < 0){
return (W + (-W/7+1) * 7) % 7;
}
return W % 7;
}
int main(){
int year, month, day;
while(~scanf("%d%d%d", &year, &month, &day)){
printf("%d\n", Change(year,month,day));
}
return 0;
}
写这么多,不容易
唔 - -