萬年歷,可查看任何日期對應的星期
注意:以下程序需要以命令行格式運行。例如,編譯後的可執行文件被命名爲filename。如果您想查看某個2002/02/01,請輸入文件名2002/01,如果您想查看2002年1月,請輸入文件名2002/01/0。
if((year % 4 = = 0 & & year % 100!= 0)| |(year % 100 = = 0 & & year % 400 = = 0))
m2 = 1;否則m2 = 0;
la_100:
switch (month)
{
case 1: dm=0; month=31; break;
case 2: dm=3; month=d==1? 29:28; break;
case 3: dm=3 m2; month=31; break;
case 4: dm=6 m2; month=30; break;
case 5: dm=1 m2; month=31; break;
case 6: dm=4 m2; month=30; break;
case 7: dm=6 m2; month=31; break;
case 8: dm=2 m2; month=31; break;
case 9: dm=5 m2; month=30; break;
case 10: dm=m2; month=31; break;
case 11: dm=3 m2; month=30; break;
case 12: dm=5 m2; month=31; break;
}
if (daymonth)
{ printf ("\n ERROR! the entered DAY is invalid\n"); exit (0); }
week=(dy dm day-1 6)%7; if(week
if (day>0)
{
switch (week)
{
case 0: strcpy (WEEK,"SUNDAY"); break;
case 1: strcpy (WEEK,"MONDAY"); break;
case 2: strcpy (WEEK,"TUESDAY"); break;
case 3: strcpy (WEEK,"WEDNESDAY"); break;
case 4: strcpy (WEEK,"THURSDAY"); break;
case 5: strcpy (WEEK,"FRIDAY"); break;
case 6: strcpy (WEEK,"SATURDAY"); break;
}
printf ("\n this day is %s \( %d \)\n\n OK!\n",WEEK,week);
}
else
{
week= week%7;
printf ("\n the calender of this month as following\n");
printf ("\n *********************************\n");
printf (" SUN MON TUE WEN THU FRI STA\n");
for (i=0;i for (i=1;i
0條評論