大家帮忙改改这个关于21点的程序,我是新手!不知道怎么改?大家帮帮忙啊
#include#include
//洗发牌
int xifapai()
{
int pai[13][4],i,j;
int a,b,x;
x=rand()%4;
switch(x)
{
case 0: cout << "黑桃:"; break;
case 1: cout << "红桃:"; break;
case 2: cout << "梅花:"; break;
case 3: cout << "方块:"; break;
}
a=rand()%13,b=rand()%4;
for(j=0;j<4;j++)
{
for(i=0;i<13;i++)
{
if(i<11)
{
pai[i][j]=i+1;
}
else
{
pai[i][j]=0.5;
}
}
}
cout<<PAI[A][B];
return pai[a][b];
}
//玩家阶段
int wanjia()
{
cout<<"玩家阶段:"<<'\n';
cout << "玩家获得牌:\t";
int sum=0;
char choice='y';
sum=xifapai()+xifapai();
cout<<"\n是否继续要牌(y/n):";
cin>>choice;
if(choice == 'y')
{
sum+=xifapai();
if(sum>21)
{
cout<<"对不起!您输了!"<<'\n';
}
else
{
cout<<"\n是否继续要牌(y/n):";
cin>>choice;
if(choice == 'y')
{
sum+=xifapai();
if(sum>21)
{
cout<<"对不起!您输了!"<<'\n';
}
else
{
cout<<"\n是否继续要牌(y/n):";
cin>>choice;
if(choice != 'y')
{
return sum;
}
else
{
sum+=xifapai();
cout<<"\n是否继续要牌(y/n):";
cin>>choice;
if(choice != 'y')
{
return sum;
}
else
{
sum+=xifapai();
return sum;
}
}
}
}
}
}
//电脑阶段
int diannao()
{
int sum2=0,x;
cout<<"电脑阶段:"<<'\n';
cout<<"电脑获得牌:\t";
sum2=xifapai()+xifapai();
x=rand()%2;
if(x==1)
{
sum2+=xifapai();
if(sum2>21)
{
cout<<"您赢了!"<<'\n';
}
else
{
x=rand()%2;
if(x==1)
{
sum2+=xifapai();
return sum2;
}
else
{
x=rand()%2;
if(x==1)
{
sum2+=xifapai();
return sum2;
}
else
{
return sum2;
}
}
}
}
}
//判断阶段
void main(void)
{
if(wajia()>diannao()&&wajia<=21)
{
cout<<"您赢了!"<<'\n';
}
else
{
cout<<"您输了!"<<'\n';
}
cout<<'\n';
}