Enter the first letter of the day of the week to determine the day of the week. If the first letter is the same, continue to judge the second letter.
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 ");
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 ");
27 else if (letter = 'H' | letter = 'H ')
28 printf ("Thursday \ n ");
29 else
30 printf ("not weekday! \ N ");
31 break;
32
33 case 'W ':
34 printf ("Wensday \ n ");
35 break;
36
37 case 'F ':
38 printf ("Friday \ n ");
39 break;
40
41 case's ':
42 printf ("please input next letter: \ n ");
43 if (letter = getch () = 'A ')
44 printf ("Satuday \ n ");
45 else if (letter = 'U' | letter = 'U ')
46 printf ("Sunday \ n ");
47 else
48 printf ("not weekday! \ N ");
49 break;
50
51 default:
52 printf ("^ v ^ not defined yet ^ v ^ \ n ");
53 break;
54}
55 // printf ("% c \ n", letter );
56}
57 return 0;
58}
From zhengmian