[清理垃圾帖子]
-------------[ 本帖最后由 BlueGuy 于 2015-6-3 20:14 编辑 ]
#include <stdio.h> char b[7][10] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; bool m[] = {false,true,false,true,false,true,false,true,true,false,true,false,true}; int main() { int year,month,day; while(~scanf("%d%d%d",&year,&month,&day)) { if((year == 0 || month == 0 || day == 0) || (month == 2 && day>29) || (!m[month] && day == 31) || (!(year%4 == 0 && year%100 != 0 ||year%400 == 0)&&month == 2 && day == 29) ) { printf("illegal\n"); continue; } if (month<3) { year -= 1; month += 12; } int c = year/100,y = year%100; int w = c/4 - 2*c +y +(y/4) +(26*(month+1)/10) + day-1; printf("%s\n",b[(w%7+7)%7]); } }