不知道哪里错了,请指教

来源:百度知道 编辑:UC知道 时间:2024/05/09 13:01:26
# include<stdio.h>

main()
{
char ch;
printf("please input the first letter:");
ch=getchar();
switch(ch)
{
case 'M':printf("Monday\n");break;
case 'T':
{
printf("please input the second letter:");
ch=getchar();
if(ch=='u') printf("Tuesday\n");
else if(ch=='h') printf("Thursday\n");
else printf("data error!\n");
}break;
case 'W':printf("Wednesday\n");break;
case 'F':printf("Friday\n");break;
case 'S':
{
printf("please input the second letter:");
ch=getchar();
if(ch=='a')
{
printf("please input the third letter:");
ch=getchar();
if(ch=='t') printf("Saturday\n");
else if(ch==&

getChar()读到的是‘\n’吧。应该有个吸收回车的getChar哦,读取最好用scanf
# include<stdio.h>

main()
{
char ch;
printf("please input the first letter:");
scanf("%c",&ch);
switch(ch)
{
case 'M':printf("Monday\n");break;
case 'T':
{
getchar();
printf("please input the second letter:\n");
scanf("%c",&ch);
if(ch=='u') printf("Tuesday\n");
else if(ch=='h') printf("Thursday\n");
else printf("data error!\n");
}break;
case 'W':printf("Wednesday\n");break;
case 'F':printf("Friday\n");break;
case 'S':
{
getchar();
printf("please input the second letter:");
scanf("%c",&ch);
if(ch=='a')
{
printf("please input the third letter:"