猜测用户的输入星期几
请输入星期几的第一个字母来判断一下是星期几,如果第一个字母一样,则继续判断第二个字母。1 #include <stdio.h>
2 #include<conio.h>
3 int main()
4 {
5 char letter;
6 printf("please input the first letter:\n");
7 while((letter = getch())!='Q'&&letter!='q')
8 {
9 printf("%c:\n",letter);
10 if(letter=='\n')
11 {
12 printf("\n");
13 continue;
14 }
15
16 switch(letter)
17 {
18 case 'M':
19 printf("Monday\n\n");
20 break;
21
22 case 'T':
23 printf("please input next letter:\n");
24 letter = getch();
25 if(letter=='U'||letter=='u')
26 printf("Tuesday\n\n");
27 else if(letter=='h'||letter=='H')
28 printf("Thursday\n\n");
29 else
30 printf("not weekday!\n\n");
31 break;
32
33 case 'W':
34 printf("Wensday\n\n");
35 break;
36
37 case 'F':
38 printf("Friday\n\n");
39 break;
40
41 case 'S':
42 printf("please input next letter:\n");
43 if((letter=getch())=='A')
44 printf("Satuday\n\n");
45 else if(letter=='U'||letter=='u')
46 printf("Sunday\n\n");
47 else
48 printf("not weekday!\n\n");
49 break;
50
51 default:
52 printf("^v^ not defined yet ^v^\n\n");
53 break;
54 }
55 //printf("%c\n",letter);
56 }
57 return 0;
58 }
摘自 zhengmian
补充:软件开发 , C语言 ,