输入一个日期计算是星期几的问题,怎么利用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 "stdio.h"
main () {
    int y,m,d,a,b;
    b = 0;
    scanf("%d%d%d", &y, &m, &d);
    if (m > 12 || m < 0) {
        b = 1;
        printf("month is error.\n");
    } else if (d < 0) {
        b = 1;
        printf("day is error.\n");
    } else {
        switch(m) {
            case 1||3||5||7||8||10||12:
                if (d > 32) {
                    b = 1;
                    printf("day is error.\n");
                }; 
                break;
            case 4||6||9||11:
                if (d > 31) {
                    b = 1;
                    printf("day is error.\n");
                }; 
                break;
            case 2:
                if((y%4==0 && y%100!=0)||(y%400==0)) a=1;
                else a=2;
                if(a==1&&d>30) {b = 1; printf("day is error.\n");}; break;
                if(a==2&&d>29) {b = 1; printf("day is error.\n");}; break;
        }
    }
    if (m == 1 || m == 2) {
        m+=12;
        y--;
    }
    if(b == 0) {
        int iWeek = (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
        switch(iWeek) {
            case 0: printf("1\n"); break;
            case 1: printf("2\n"); break;
            case 2: printf("3\n"); break;
            case 3: printf("4\n"); break;
            case 4: printf("5\n"); break;
            case 5: printf("6\n"); break;
            case 6: printf("0\n"); break;
        }
    }
    system("pause");
}