跳到正文

个人记录

数字记忆游戏

_Los约 2 分钟
原文
文章信息与版本

文章信息

发布
2018年7月14日
收录
2025年12月12日
更新
2026年11月15日
篇幅
约 2 分钟
获赞
1

版本

  1. v1当前
C++
#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指的是每一个数字出现的时间。


上一篇:简易控制台画板

下一篇:方块记忆游戏

原文