常用的C++黑框框键盘选择
介绍:可以灵敏地感应键盘输入来选择,无需回车,容错空间大
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
while (1)
{
cout << "\n\n\n\t\t\t\t---欢迎使用A-Soul图书管理系统---" << endl;
cout << "\n\t\t\t\t\t---作者:贝极星---" << endl;
cout << "\n\t\t\t\t\t---1.功能1---" << endl;
cout << "\n\t\t\t\t\t---2.功能2---" << endl;
cout << "\n\t\t\t\t\t---3.功能3---" << endl;
cout << "\n\t\t\t\t\t---4.功能4---" << endl;
cout << "\t\t\t\t\t\t\t\t\t 按Esc键退出" << endl;
cout << "\n\n\t\t\t\t请输入功能选项:";
int choice = 0;
choice = _getch(); //直接检验键盘输入
if (choice == 27) //27对应esc键
{
break;
}
system("cls"); //清屏操作
switch (choice)
{
case 49:
cout << "功能1:" << endl;
system("pause");
system("cls");
break;
case 50:
cout << "输入下架图书的ISBN号:" << endl;
system("pause");
system("cls");
break;
case 51:
cout << " 按1输入ISBN号删除" << endl;
cout << " 按2读取删除文件" << endl;
choice = _getch();
if (choice == 49)
{
cout << "按了1"<<endl;
}
else cout<<"按了2"<<endl;
system("pause");
system("cls");
break;
case 52:
system("pause");
system("cls");
break;
default:
break;
}
}
return 0;
}