超级按数字

xuzihang 2020-06-16 22:39:34 3
#include<iostream>
#include<windows.h>
#include<conio.h>
#include<ctime>
using namespace std;

int main(){
	char answer = 'a';
	while(answer!='0'){
		srand(unsigned(time(NULL)));
	    int des = rand() % 100;
		cout<<"您的目标范围:"<<des<<"~"<<des+5<<endl;
	    cout<<"是否开始?(按任意键开始,开始后按任意键停止计时):";
	
	    if(getch()){
		    int count = 0;
	        while(!kbhit()){
		        system("cls");
		        cout<<"您的目标范围:"<<des<<"~"<<des+5<<endl;
		        cout<<count;
		        count++;
	        }
	        
	        answer = getch();
	        count--;
	        cout<<endl;
	    
	        if(count>=des && count<=des+5){
		        cout<<"你赢了!"<<endl;
	        }
	        else{
	        	cout<<"你输了!"<<endl;
	        }
	    }
        
        cout<<endl;
        cout<<"是否重新开始?(输入0结束游戏,其他任意键重新开始):";
        answer = getch();
        cout<<endl; 
        if(answer != '0')
		    system("cls"); 
	}
	
	system("pause");
	return 0;
}
{{ vote && vote.total.up }}

共 1 条回复

chen_zhe 沙雕

这游戏是来搞笑的吗。。。。。编mc累了来写这个了