从输入的第一个字母或第二个来识别星期几
#include "stdafx.h"#include "stdio.h"
int main(int argc, char* argv[])
{ //Sunday\Monday\Tuesday\Wednesday\Thursday\Friday\Saturday
char c;
printf("please enter the first number:\n");
while((c=getchar())!='\n')
{
switch(c)
{case 'S':
printf("please enter the second number:\n");
if((c=getchar())=='a')
printf("Saturday.\n");
else if((c=getchar())=='u')
printf("Sunday.\n");
else
printf("error data.\n");break;
case 'M':
printf("Monday.\n");break;
case 'T':
printf("please enter the second number:\n");
if((c=getchar())=='u')
printf("Tuesday.\n");
else if((c=getchar())=='h')
printf("Thursday.\n");
else
printf("error data.\n");break;
case 'W':printf("Wednesday.\n");break;
case 'F':printf("Friday.\n");break;
default:printf("error input.\n");
}
}
return 0;
}
这个程序在进行Saturday和Tuesday选择会出错