c++娱乐代码

//数字炸弹游戏代码!!! :grinning:
//下面,代码开始——

#include <bits/stdc++.h>
#include<time.h>
#include<unistd.h>
using namespace std;
int x,y,z=1,k,n,w,s;
int main() {
system(“color 92”);
srand(time(NULL));
cout<<“数字炸弹游戏开始!”<<‘\n’;
cout<<“请输入玩家个数:” ;
cin>>y;
cout<<“请输入范围1~”;
cin>>k;
s=rand()%k+1;
x=s;
cout<<“OK,游戏…”<<‘\n’;
sleep(1);
system(“color c4”);
cout<<“开始!”<<‘\n’;
sleep(2);
system(“color f4”);
while(1) {
for(int i=1; i<=y; i++) {
cout<<“玩家”<<i<<“,请选择数字”<<z<<“~”<<k<<‘\n’;
cin>>n;
if(x==n) {
sleep(1);
system(“color f0”);
cout<<“砰!玩家”<<i<<“被炸死了!游戏结束!”;
return 0;
} else {
if(n>k or n<z) {
while(n>k or n<z) {
cout<<“玩家”<<i<<“,请重新选择数字”<<z<<“~”<<k<<‘\n’;
cin>>w;
n=w;
}
}
if(n>x) {
k=n-1;
} else {
z=n+1;
}
}
}
}
}

9 个赞

用一下格式化,不然引号都变成中文的了

7 个赞

over
:grinning:

2 个赞

???

1 个赞

在开头加上这个"```"

114514
3 个赞

哦,是变成中文的了

修改了一下,增加了违规出局和继续游戏
#include <bits/stdc++.h>
#include<time.h>
#include<unistd.h>
using namespace std;
int x,y,z=1,k,n,w,s;
int main() {
srand(time(NULL));
int m=0;
cout<<“数字炸弹游戏开始!”<<endl;
cout<<“请输入玩家个数:” ;
cin>>y;
bool arr[y+1];
bool c;
for(int v=1;v<=y;v++){
arr[v]=true;
}
cout<<“请输入范围1~”;
cin>>k;
int l=k;
s=rand()%k+1;
x=s;
cout<<“OK,游戏…”<<endl;
cout<<“开始!”<<endl;
while(1) {
for(int i=1; i<=y; i++) {
if(arr[i]==false){
continue;
}
m=0;
c=false;
cout<<“玩家”<<i<<“,请选择数字”<<z<<“~”<<k<<endl;
cin>>n;
if(x==n) {
cout<<“砰!玩家”<<i<<“被炸死了!”;
arr[i]=false;
k=l;
s=rand()%k+1;
x=s;
for(int u=1;u<=y;u++){
if(arr[u]==true){
c=true;
}
}
if(c==false){
cout<<“游戏结束!”;
return 0;
}
if(i==y){
i=1;
}
else{
i++;
}
m=0;
continue;
}
else {
if(n>k or n<z) {
while(n>k or n<z) {
cout<<“玩家”<<i<<“,请重新选择数字”<<z<<“~”<<k<<endl;
cin>>w;
n=w;
m++;
if(m>=3){
cout<<“玩家”<<i<<“已多次违规,出局!”;
arr[i]=false;
if(i==y){
i=1;
}
else{
i++;
}
m=0;
continue;
}
}
}
if(n>x) {
k=n-1;
}
else {
z=n+1;
}
}
}
}
return 0;
}

6 个赞

都过一个月的帖子了就不要回复了

2 个赞