menu.c

来自「编写一程序」· C语言 代码 · 共 92 行

C
92
字号
#include "Score.h"

//显示功能菜单,返回选择的菜单项
int Menu()
{
	int menuitem ;
	int item;
	while(1)
	{
		menuitem = -1;
		item = -1;
		while ( menuitem != 0 && menuitem != 1 && menuitem != 2 && menuitem != 3 )
		{
			//clrscr();
			zhg_information();
                        printf("\n\t\t\t   Welcom to use this program!\n");
                        printf("\n\t\tCopyright (c) 2006 by zhg & Whu Computer Center.");
			printf("\n\n\n\n\t\t\t\t  Main Menu\n") ;		
			printf("\n\t\t\t\t1. Sort\n");
			printf("\t\t\t\t2. Statistics\n");
			printf("\t\t\t\t3. Search\n");
			printf("\t\t\t\t0. Exit\n\n");
			printf("\t\t\tPlease choose an item(0-3):  ");
			scanf("%d",&menuitem);
			if (menuitem == 0 || menuitem == -1) exit(0);
		}
		switch(menuitem)
		{
		case 1:
			{
				while(item != 0 && item != 1 && item != 2 && item != 3 && item != 4)
				{
					clrscr();
					printf("\n\t\t  Sort Menu\n");
					printf("\n\t\t1. Sort by Math score\n");
					printf("\t\t2. Sort by English score\n");
					printf("\t\t3. Sort by Computer score\n");
					printf("\t\t4. Sort by Sum score\n");
					printf("\t\t0. return\n\n");
					printf("\tPlease choose an item(0-4):");
					scanf("%d",&item);
					if (item == 0 || item == -1) break;
				}

				switch(item)
				{
				case 1:
					return MATH_SORT;
				case 2:
					return ENGLISH_SORT;
				case 3:
					return COMPUTER_SORT;
				case 4:
					return SUM_SORT;
				}
				break;
			}
		case 2:
			{
				while(item != 0 && item != 1 && item != 2 && item != 3 && item != 4)
				{
					clrscr();
					printf("\n\t\t  Statitics Menu\n");
					printf("\n\t\t1. Statitics by Math score\n");
					printf("\t\t2. Statitics by English score\n");
					printf("\t\t3. Statitics by Computer score\n");
					printf("\t\t0. return\n\n");
					printf("\tPlease choose an item(0-4):");
					scanf("%d",&item);
					if (item == 0) break;
				}

				switch(item)
				{
				case 1:
					return MATH_STATISTICS;
				case 2:
					return ENGLISH_STATISTICS;
				case 3:
					return COMPUTER_STATISTICS;
				case 4:
					return SUM_STATISTICS;
				}
				break;
			}
		case 3:
			{
				return SEARCH;
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?