| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 234 人关注过本帖
标题:大家帮忙改改这个关于21点的程序,我是新手!不知道怎么改?大家帮帮忙啊
取消只看楼主 加入收藏
紫竹食客
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2012-3-21
收藏
 问题点数:0 回复次数:0 
大家帮忙改改这个关于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';
}
搜索更多相关主题的帖子: include 21点 
2012-03-22 21:14
快速回复:大家帮忙改改这个关于21点的程序,我是新手!不知道怎么改?大家帮帮忙 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017796 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved