#include <stdio.h>

//利用泰勒公式计算星期几
//w=y+[y/4]+[c/4]-2c+[26(m+1)/10]+d-1 
int getweek(int year,int month,int day)
{
	int w;    //星期
	int c;    //世纪-1 YYYY的头两位
	int y;    //年份   YYYY的后两位
	int m;    //月份 >=3 1月 2月看成上年的13月 14月
	int d=day;    //日
	if(month>=3) 
	{
		c=year / 100;
		y=year % 100;
		m=month;
	}
	else
	{
		m=month+12;
		y=(year-1) % 100;
		c=(year-1) / 100;
	}
	w=y+y/4+c/4-2*c+(26*(m+1))/10+d-1;
	w=(w+700) %7;
	return w;
}

bool y_check(int year,int month,int day)
{
    if(year>2100 || year<1800) return false;
    if (month>12) return false;
    if (day>31) return false;
    return true;
}
int main()
{
	char* wweek[]={"日","一","二","三","四","五","六"};
    int year,month,day;
_input:
    printf("请输入阳历年月日例如2012,11,30-->");
    scanf("%d,%d,%d",&year,&month,&day);
    if(y_check(year,month,day)==false) 
    {
        printf("输入日期有错误,请重新输入\n");
        goto _input;
    }
	int week=getweek(year,month,day);
    printf("%d年%d月%d日是星期%s\n",year,month,day,wweek[week]);
    return 0;

}