[Games] 数字炸弹 2P
version 1.0
游戏性说明
首先输入数字炸弹生成的最大限制值,接着两人轮流猜数.
每个人猜的数越接近当前中点,得分越高.
猜中炸弹的人分数大量减少.
得分高者胜利.
#include <ctime>
#include <iostream>
#include <windows.h>
#include <cstdlib>
using namespace std;
int m,r=100,l,d,tot[3],p=1;
int main(){
srand(time(NULL));
cout<<"max as >>";
cin>>r;
m=rand()%(r-1)+1;
while(1){
cout<<"Player 1 : "<<tot[1]<<" Scores."<<endl<<"Player 2 : "<<tot[2]<<" Scores."<<endl<<endl;
cout<<"Player "<<p<<endl;
cout<<"A number from "<<l<<" to "<<r<<" >>";
cin>>d;
if(d>r||d<l){
system("cls");
cout<<"Error. Score -100."<<endl<<endl<<endl;
tot[p]-=100;
continue;
}
if(d==m){
tot[p]/=3;
tot[p]*=2;
system("cls");
break;
}
else if(d>m){
system("cls");
cout<<"Score + "<<(r-d)*10000/(r-l)+50<<endl<<endl;
tot[p]+=(r-d)*10000/(r-l)+50;
r=d-1;
}
else{
system("cls");
cout<<"Score + "<<(d-l)*10000/(r-l)+50<<endl<<endl;
tot[p]+=(d-l)*10000/(r-l)+50;
l=d+1;
}
if(p==1){
p=2;
}
else{
p=1;
}
}
cout<<"GameOver ."<<endl<<endl<<"Player 1 : "<<tot[1]<<" Scores."<<endl<<"Player 2 : "<<tot[2]<<" Scores."<<endl<<endl;
if(tot[1]>tot[2]){
cout<<"Player 1 Win!"<<endl;
}
else if(tot[2]>tot[1]){
cout<<"Player 2 Win!"<<endl;
}
else{
cout<<endl;
}
system("pause");
}