发布网友 发布时间:2022-04-24 13:28
共2个回答
热心网友 时间:2023-10-14 10:51
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
using namespace std;
void xuanzepaixu() //选择排序函数
{
printf("待添加,请按任意键继续...");
getchar();
}
void erfenpaixu() //二分查找函数
{
printf("待添加,请按任意键继续...");
getchar();
}
void menu() //主菜单
{
system("cls"); //清屏
printf("\n\t\t\t 菜单\n");
printf("\t\t\t#***********************#\n");
printf("\t\t\t# 1选择排序 #\n");
printf("\t\t\t# 2二分查找 #\n");
printf("\t\t\t# 3返回 #\n");
printf("\t\t\t# 4---关闭 #\n");
printf("\t\t\t#***********************#\n");
printf("\t\t\t 请选择(1-4) =:");
}
void main()
{
char select;
while(1)
{
menu();
system("COLOR 9f");
scanf("%c",&select);
if(select=='3')
break; //返回上级菜单
else
{
getchar(); //读入回车符
if(!isdigit(select)) //如果不是数字字符
{
printf("\n\7Your select may be wrong, must enter the digit!\n");_getch();
}
else
{
switch (select)
{
case '1': xuanzepaixu();break;
case '2': erfenpaixu();break;
case '4':exit(0); //直接退出
default:
{
printf("\n\7\7Your selected digit may be wrong, select again!\n");
_getch();
break;
}
}
}
}
};
}
已经调试过,添加功能函数就行了,当然上面的菜单还是用dos界面打印的,如果想用windows,那就要用MFC了。
热心网友 时间:2023-10-14 10:51
system("cls");
printf("1.选择排序\n2.二分查找\n3.返回\n");