普伐他汀钠片的副作用:哪位高手可以给我一个简单的C语言游戏程序,要有大概解释的

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 01:03:00
越简单越好 ,最好有大概的每步解释!

//简单游戏。。哈哈,暴简单
游戏:

#include<iostream.h>
#include<stdlib.h>
#include<time.h>
#include<iomanip.h>
#include<stdio.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;

}