通过按下"a"中断循环,再次按下“a”重新开始已经被中断的循环,按下“b”结束。
小白瞎写,各位大神嘴上饶人
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
int i, j,c=0;
char k;
while (1) {
if (_kbhit()) {
k = _getch();
if (k == 98)
return 0;
if (k == 97)
c++;
}
while (c % 2 == 0) {
if (_kbhit()) {
k = _getch();
if (k == 98)
return 0;
if (k == 97)
c++;
}
for (i = 0;i < 10;i++) {
for (j = 0;j < i;j++) {
cout << "*";
}
cout << endl;
}
}
}
system("pause");
return 0;
}