运用C语言的编程技术输入一个日期字符串求解它是星期几的问题怎么实现呢?

Problem Description
Today is Saturday, 17th Nov,2007. Now, if i tell you a date, can you tell me what day it is ?

Input
There are multiply cases.
One line is one case.
There are three integers, year(0<year<10000), month(0<=month<13), day(0<=day<32).

Output
Output one line.
if the date is illegal, you should output "illegal". Or, you should output what day it is.

Sample Input
2007 11 17

Sample Output
Saturday

#include
int main ()
{
int y, m, d, c, w;
printf ("输入年 月 日(空格间隔):");
scanf ("%d %d %d", &y, &m, &d);
if (m ==1 || m == 2) { //判断月份是否为1或2
y--;
m += 12;
}
c = y / 100;
y = y - c * 100;
w = (c / 4) - 2 * c + (y + y / 4) + (13 * (m + 1) / 5) + d - 1;
while (w < 0) w += 7;
w %= 7;
if (w == 0) printf ("星期日");
else printf ("星期%d", w);
return 0;
}
/* #include 后面 stdio.h 库文件用<>括起来 这里不让打出来特说明一下*/