⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yaosezi.txt

📁 一个摇塞子游戏
💻 TXT
字号:
#include<iostream.h> 
#include<stdlib.h> 
#include<time.h> 
#include<iomanip.h> 
#include<stdio.h>
#include<math.h> 
void main() 
{int i,j,m=8,n=8,h,k,l,d,s=2;char q,w; 
char a[]={'*','>','>','>','>','>','>','>','>','>','>','>','>','>','>','>'}; 
char b[]={'*','>','>','>','>','>','>','>','>','>','>','>','>','>','>','>'}; 


cout<<" "<<"欢迎进入游戏!"<<endl; 
cout<<endl; 
cout<<endl; 
cout<<"双方的棋子数目:"<<endl<<endl<<endl; 

cout<<"甲方: "; 
for(i=0;i<n;i++) 
{cout<<a[i]<<setw(3);} 
cout<<endl; 
cout<<"乙方: "; 
for(j=0;j<m;j++) 
{cout<<b[j]<<setw(3);} 

cout<<endl<<endl<<endl; 
cout<<"按键摇骰子"<<endl<<endl; 
cout<<"ROUND"<<" "<<"1"<<endl; 
while(n!=0&&m!=0) 
{cout<<"请甲方按X键摇骰子!"<<endl; 
cout<<endl; 
srand(time(0)); 
do 
h=rand(); 
while(h<1||h>6); 
q=getchar(); 
if(q=='x') 
cout<<"甲点数:"<<h<<endl<<endl; 

cout<<"请乙方按Z键摇骰子!"<<endl<<endl; 
w=getchar(); 
do 
{srand(time(0)); 
do 
k=rand(); 
while(k<1||k>6); 
}while((w=getchar())=='z'); 
cout<<"乙点数:"<<k<<endl; 


if(h>k) 
{cout<<endl; 
cout<<"甲方胜!"<<endl<<endl;; 
cout<<"请甲方选择1攻击或加选择2强防守"<<endl; 
cin>>l; 
if(l==1) 
{cout<<"甲方选择攻击!"<<endl; 
cout<<"现在双方棋子数目:"<<endl<<endl; 
cout<<"甲方: "; 
for(i=0;i<n;i++) 
{cout<<a[i]<<setw(3);} 
cout<<endl; 
m=m-1; 
cout<<"乙方: "; 
for(j=0;j<m;j++) 
{cout<<b[j]<<setw(3);} 
cout<<endl; 
cout<<"***************************"<<endl; 
cout<<"ROUND"<<" "<<s<<endl<<endl; 
s++; 
} 
if(l==2) 
{cout<<"甲方选择加强防守!"<<endl; 
cout<<"现在双方棋子数目:"<<endl<<endl; 
n=n+1; 
cout<<"甲方: "; 
for(i=0;i<n;i++) 
{cout<<a[i]<<setw(3);} 
cout<<endl; 
cout<<"乙方: "; 
for(j=0;j<m;j++) 
{cout<<b[j]<<setw(3);} 
cout<<endl; 
cout<<"***************************"<<endl; 
cout<<"ROUND"<<" "<<s<<endl<<endl; 
s++; 

} 

} 
if(h<k) 
{cout<<endl; 
cout<<"乙方胜!"<<endl<<endl;; 
cout<<"请乙方选择1攻击或选择2加强防守"<<endl; 
cin>>d; 
if(d==1) 
{cout<<"乙方选择攻击!"<<endl; 
cout<<"现在双方棋子数目:"<<endl<<endl; 
n=n-1; 
cout<<"甲方: "; 
for(i=0;i<n;i++) 
{cout<<a[i]<<setw(3);} 
cout<<endl; 
cout<<"乙方: "; 
for(j=0;j<m;j++) 
{cout<<b[j]<<setw(3);} 
cout<<endl; 
cout<<"***************************"<<endl; 
cout<<"ROUND"<<" "<<s<<endl<<endl; 
s++; 
} 
if(d==2) 
{cout<<"乙方选择加强防守!"<<endl; 
cout<<"现在双方棋子数目:"<<endl<<endl; 
cout<<"甲方: "; 
for(i=0;i<n;i++) 
{cout<<a[i]<<setw(3);} 
cout<<endl; 
m=m+1; 
cout<<"乙方: "; 
for(j=0;j<m;j++) 
{cout<<b[j]<<setw(3);} 
cout<<endl; 
cout<<"***************************"<<endl; 
cout<<"ROUND"<<" "<<s<<endl<<endl; 
s++; 
} 
if(h==k)continue; 
} 
}if(n==0)cout<<"乙方胜啦,甲方滚蛋吧!"<<endl; 
if(m==0)cout<<"甲方胜啦,乙方滚蛋吧!"<<endl; 

} 
  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -