我正在开发一个简单的程序,其中包含2或3个简单的游戏,例如“ man子手”和“井字游戏”。在这里,当用户在黑白中的任意位置按 ESC 时,它应该退出,并且当用户按 CTRL 时,它也应该切换游戏。该怎么做?
#include "iostream"
#include "ctime"
#include "cstdlib"
#include "cstdio"
#include <stdlib.h>
using namespace std;
int main()
{
cout << "Test\n" << endl;
srand((int)time(0));
int s, x, run = 0;
cin >> s;
for (int i = 0; i < 6; ++i)
{
int r = rand() % 6 + 1;
if (r == s)
{
cout << "U:" << s << endl << "AI:" << r << endl << "OUT!!!";
break;
}
cout << "U:" << s << endl << "AI:" << r << endl;
run += s;
system("pause");
cin >> s;
system("cls");
}
cout << "total runs =" << run << endl;
system("pause");
}