数字记忆游戏
_Los
·
·
个人记录
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <windows.h>
using namespace std;
int speed,cnt=0;
string rs(int len){
string s="";
for(int i=1;i<=len;i++){
char a=rand()%57+1;
while(a<'0' || a>'9')a=rand()%57+1;
s+=a;
}
return s;
}
int main(){
srand((unsigned)time(NULL));
cout<<"Welcome to play the Number Memory Game(By _Los)."<<endl<<endl;
cout<<"Please input the speed(second):";
cin>>speed;
string que,in;
do{
cnt++;
system("cls");
cout<<"Round "<<cnt;
_sleep(1000);
que=rs(cnt+2);
system("cls");
cout<<"Remember it!"<<endl<<endl;
cout<<que<<endl;
_sleep(speed*1000);
system("cls");
cout<<"The number is:";
cin>>in;
}while(que==in);
system("cls");
cout<<"You lost!"<<endl<<"You have played "<<cnt-1<<" turns."<<endl;
return 0;
}
注意事项:Speed指的是每一个数字出现的时间。
上一篇:简易控制台画板
下一篇:方块记忆游戏