Guess the user's input day of the week

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.