跳到正文

休闲·娱乐

数字炸弹

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

文章信息

发布
2024年10月28日
收录
2025年12月12日
更新
2026年11月17日
篇幅
约 2 分钟

版本

  1. v1当前

点个赞吧

C++
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int slow(string sss,int bb){
	for(int i=0;i<sss.size();i++){
		cout<<sss[i];
		_sleep(bb);
	}
}
int main(){
	int a,b,c,d;
	system("color e4");
	slow("欢迎来到数字炸弹",10);
	_sleep(100);
	slow("作者:zhaoxinze\n修改:zexinzhao\n",10);
	_sleep(100);
	slow("1、单人模式2、双人模式\n",10);
	cin>>a;
	if(a==1){
		system("cls");
		cout<<"输入1到几:";
		cin>>c; 
		srand(time(0));
		b=rand()%c+1;
		for(int i=0;;i++){
			cout<<"\n1到"<<c<<"中选一个数:";
			cin>>d;
			if(d>b)
				cout<<"\n大了";
			if(d<b)
				cout<<"\n小了";
			if(d==b){
				cout<<"\n答对了\n";
				_sleep(100);
				slow("用时",10);
				cout<<i;
				_sleep(10);
				cout<<"次";
				return 0;
			} 
		}
	}
	if(a==2){
		system("cls");
    cout<<"输入炸弹\n";
		cin>>b;
    system("cls");
		for(int i=0;;i++){
			cin>>c;
			if(c>b){
				cout<<"\n大了";
			}
			if(c<b){
				cout<<"\n小了";	
			}
			if(c==b){
				cout<<"\n答对了\n";
				_sleep(100);
				slow("用时",10);
				cout<<i;
				_sleep(10);
				cout<<"次";
				return 0;
			}
		}
	}
	return 0;
}
原文