输入首字母就就能判断是星期几,当我输入‘s’后,再输入‘u’,回车显示sunday,但是输入'a',回车却不显示saturday,类似的thursday显示,t
#include"stdio.h"int main()
{ char letter;
printf("please input a letter:\n");
while((letter=getchar())!='y')
{switch(letter)
{ case's':
printf("please enter second letter:\n");
if((letter=getchar())=='a')
printf("saturday\n");
else if((letter=getchar())=='u')
printf("sunday\n");
else
printf("error\n");
break;
case't':
printf("please enter second letter:\n");
if((letter=getchar())=='u')
printf("tuesday\n");
else if((letter=getchar())=='h')
printf("thursday\n");
else
printf("error\n");
break;
case 'f':
printf("friday\n");
break;
case 'w':
printf("wednesday\n");
break;
case 'm':
printf("monday\n");
break;
}
}
printf("error\n");
return 0;
}