Current location - Recipe Complete Network - Complete cookbook - Design a simple and practical menu through C language, select different menu items through the menu and realize the corresponding functions.
Design a simple and practical menu through C language, select different menu items through the menu and realize the corresponding functions.
# include & ltstdio.h & gt

# include & ltwindows.h & gt

//\n 1。 Increase? 2. query? 3. Delete? 4. Exit \ n ");

//Declare a function

Invalid? addnd();

Invalid? search nd();

Invalid? printnd();

Invalid? charund();

//Including? Enumeration type? Branch switch

enum? Mmenu{/* Define an enumeration type named Mmenu?

Constants can have certain meanings (such as implementation menu) */

Addn= 1,//The default value is 0, which is defined as after 1? Subsequent members are also automatically converted (sorted).

searchn,

printn,

quitn

};

Invalid? main(){

enum? Menu? Input;

while( 1){

Printf ("Menu \n 1。 Supplement? 2. query? 3. print? 4. Exit \ n ");

Scanf("%d ",& input);

Sleep (500);

System ("CLS");

What happened in switch(input){//case? Can only be an integer or a character constant.

Case? Addn:printf (" 1 is selected. add \ n "); addnd(); Break;

Case? Searchn:printf ("2。 Query the selected \ n "); search nd(); Break;

Case? Printn:printf ("3。 Print the selection \ n "); printnd(); Break;

Case? Quitn:printf ("4。 Exit the selected \ n "); Exit (0); Break;

Default? : printf ("is not in the option, please re-enter! \ n "); Break; }

};

}

Invalid? Addnd(){// add

Printf("// Please customize the addnd () function code//\ n ");

}

Invalid? searchnd(){

Printf("// Please customize the searchnd () function code//\ n ");

}

Invalid? Printnd(){// print

Printf("// Please customize the code of printnd () function//\ n "); ?

}

Invalid? charund(){

Printf("// Please customize the charund function code//\ n "); ?

}