簡易音游底力練習(xí)器源代碼-第一次修改
#include <bits/stdc++.h>
#include <ctime>
#include <conio.h>
using namespace std;
int main() {
cout << "請按照屏幕上的字符\"√\"按下鍵盤按鍵(1:D,2:f,3:J,4:K)\n按任意鍵開始游戲\n";
getch();
system("cls");
int d = 0;
time_t start = time(0);
srand(time(0));
int Miss = 0, Tap = 0, b;
char a[4] = {'d', 'f', 'j', 'k'}, c;
while (time(0) - start < 15) {
b = rand() % 3;
switch (b) {
case 0:
cout << "√ × × ×\n";
break;
case 1:
cout << "× √ × ×\n";
break;
case 2:
cout << "× × √ ×\n";
break;
case 3:
cout << "× × × √\n";
break;
}
c = getch();
if (c == a[b]) {
Tap++;
} else {
d = time(0) - start;
cout << "您擊錯了。\n";
system("cls");
break;
}
system("cls");
}
if (d == 0) {
cout << "擊中:" << Tap << " 耗時約20\"";
} else {
cout << "擊中:" << Tap << " 耗時約" << d << '\"';
}
for (;;) {
}
}