跳到正文

Lcs2013

1609775

这次 S组 ,我一定会拿回我失去的所有

这是 2026年10月19日 存档的第 1 版,不是当前版本。查看当前版本

资料、奖项与版本

资料

编号
1609775
抓取

奖项

2025 CSP-J
一等奖

版本

  1. v2当前
  2. v1
C++
//中文版数字炸弹
#include<bits/stdc++.h>
using namespace std;
string s[110],name;
int vis[110],y,cnt,l,r,x,n,f;
int main(){
	cout<<"多人PK还是人机对战?人机对战输入1,多人PK输入2:";
	cin>>f;
	if(f==1){
		cout<<"请输入名称:";
		cin>>name;
		cout<<"对战开始"<<endl; 
		l=1;
		r=100;
		srand(time(0));
		x=rand()%100+1;
		while(1){
			cout<<"请"<<name<<"输入数字:范围"<<l<<"~"<<r<<endl;
			while(1){
				cin>>y;
				if(y>=l&&y<=r) break;
				cout<<"请重新输入";
			}
			if(y<x){
				l=y+1;
			}
			else if(y>x){
				r=y-1;
			}
			else{
				cout<<"炸弹爆炸"<<name<<"淘汰,人机获胜"<<endl;
				break;
			}
			y=rand()%100+1;
			cnt=l;
			for(int p=1;p<=y;p++){
				cnt++;
				if(cnt>r) cnt=l;
			}
			cout<<"人机选择输入:"<<cnt<<endl; 
			if(cnt<x){
				l=cnt+1;
			}
			else if(cnt>x){
				r=cnt-1;
			}
			else{
				cout<<"炸弹爆炸人机淘汰,"<<name<<"获胜"<<endl;
				break;
			}
		}
	}
	else{
		cout<<"请输入玩家数:";
		cin>>n;
		for(int i=1;i<=n;i++){
			cout<<"请第"<<i<<"位玩家输入名称:";
			cin>>s[i];
		} 
		for(int i=n;i>=2;i--){
			srand(time(0));
			x=rand()%100+1;
			cout<<"第"<<n-i+1<<"局游戏,开始"<<endl;
			cnt=0;
			l=1;
			r=100;
			while(1){
				cnt++;
				if(cnt>n) cnt=1;
				if(vis[cnt]) continue;
				cout<<"请"<<s[cnt]<<"输入数字:范围"<<l<<"~"<<r<<endl;
				while(1){
					cin>>y;
					if(y>=l&&y<=r) break;
					cout<<"请重新输入";
				}
				if(y<x){
					l=y+1;
				}
				else if(y>x){
					r=y-1;
				}
				else{
					cout<<"炸弹爆炸"<<s[cnt]<<"淘汰"<<endl;
					vis[cnt]=1;
					break;
				}
			}
		} 
		for(int i=1;i<=n;i++){
			if(!vis[i]) cout<<"恭喜"<<s[i]<<"获得胜利";
		} 
	}
}
//英文版数字炸弹
#include<bits/stdc++.h>
using namespace std;
string s[110],name;
int vis[110],y,cnt,l,r,x,n,f;
int main(){
	cout<<"people or computer ? computer input 1 , people input 2 :";
	cin>>f;
	if(f==1){
		cout<<"please input your name :";
		cin>>name;
		cout<<"ready-go!"<<endl; 
		l=1;
		r=100;
		srand(time(0));
		x=rand()%100+1;
		while(1){
			cout<<"please "<<name<<" input number : scope "<<l<<"~"<<r<<endl;
			while(1){
				cin>>y;
				if(y>=l&&y<=r) break;
				cout<<"please input again";
			}
			if(y<x){
				l=y+1;
			}
			else if(y>x){
				r=y-1;
			}
			else{
				cout<<"bomb explosion , "<<name<<" die , computer is win !"<<endl;
				break;
			}
			y=rand()%100+1;
			cnt=l;
			for(int p=1;p<=y;p++){
				cnt++;
				if(cnt>r) cnt=l;
			}
			cout<<"computer choose "<<cnt<<endl; 
			if(cnt<x){
				l=cnt+1;
			}
			else if(cnt>x){
				r=cnt-1;
			}
			else{
				cout<<"bomb explosion , computer is die , "<<name<<" is win !"<<endl;
				break;
			}
		}
	}
	else{
		cout<<"please input number of players :";
		cin>>n;
		for(int i=1;i<=n;i++){
			if(i==1) cout<<"please have the 1st player input name :";
			else if(i==2) cout<<"please have the 2nd player input name :";
			else if(i==3) cout<<"please have the 3rd player input name :";
			else cout<<"please have the "<<i<<"th player input name :";
			cin>>s[i];
		} 
		for(int i=n;i>=2;i--){
			srand(time(0));
			x=rand()%100+1;
			if(n-i+1==1) cout<<"the 1st game , begin :"<<endl;
			else if(n-i+1==2) cout<<"the 2nd game , begin :"<<endl;
			else if(n-i+1==3) cout<<"the 3rd game , begin :"<<endl;
			else cout<<"the "<<n-i+1<<"th game , begin!"<<endl;
			cnt=0;
			l=1;
			r=100;
			while(1){
				cnt++;
				if(cnt>n) cnt=1;
				if(vis[cnt]) continue;
				cout<<"please "<<s[cnt]<<" input number : scope "<<l<<"~"<<r<<endl;
				while(1){
					cin>>y;
					if(y>=l&&y<=r) break;
					cout<<"please input number again";
				}
				if(y<x){
					l=y+1;
				}
				else if(y>x){
					r=y-1;
				}
				else{
					cout<<"bomb explosion , "<<s[cnt]<<" is die"<<endl;
					vis[cnt]=1;
					break;
				}
			}
		} 
		for(int i=1;i<=n;i++){
			if(!vis[i]) cout<<s[i]<<" is win!";
		} 
	}
}

2048:https://apps.ak-ioi.com/oi-2048/

花朵:https://florr.io

桌游:https://game.hullqin.cn/

OJ运营模拟:https://chenzheaya.github.io/OnlineJudgeMaintainerSimulator/

领地战:https://kiomet.com/

画图:https://csacademy.com/app/graph_editor/