屏幕上随机不断闪现人员名单,按下键盘任意键时,锁定中将人员名单
#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
#include<conio.h>
using namespace std;
int main()
{
srand(time(NULL));
int i;
string s[3]={"李逵","宋江","武大郎"};
while(true)
{
system("cls");//清屏
i=rand()%3;
cout<<"the winner is:"<<s[i]<<endl;
if(kbhit())break;//如果敲击键盘任意键,结束//kbhit()包括在conio.h里
}
system("pause");//系统暂停
return 0;
}