10楼的 两个都是爆牌啊 当然是平局了

 2006-07-24 23:53
	    2006-07-24 23:53
  我又对程序做了点修改
#include <iostream>
#include <stdlib.h>
#include <ctime>
using namespace std;
//金钱类
class money
{public:
    money(){M=50;}
    int shift(int a,int b);
 private:
   int M;
};
//21点类
class point21
{public:
    void Sru();
    void Cli();
    void display();
private:
    int a;
    int b;
    money c;
};
//21点程序
void point21::Sru()
{int i=1,j=0; char c;
b=0;a=0;
srand(time(0));
while(j==0)
{if(b<13)
    {if(rand()%6<4)
        b+=(rand()%9+1);}
else if(b>=13&&b<=21)
    {if(rand()%6<2)
        b+=(rand()%9+1);}
if(b>18)j=1;
}
while(i==1)
{
    cout<<"要牌请按Y/y,亮牌请按T/t: "<<endl;
    cin>>c;
    if(c=='y'||c=='Y')
    {a+=(rand()%9+1);cout<<"您的牌点是:"<<a<<endl;}
    if(c=='T'||c=='t')
        i=0;}
}
void point21::Cli()
{cout<<"您的牌点是:"<<a<<"    "<<"电脑的牌点是:"<<b<<endl;
a=21-a;
b=21-b;
}
void point21::display()
{int x;
if(a>=0&&b>=0)
     {if(a<b)
        {
            cout<<"您胜利赢了10枚金币"<<endl;
            cout<<"您还有 "<<c.shift(10,x=1)<<" 枚金币"<<endl;}
            else if(a>b)
                {
                    cout<<"您输了10枚金币"<<endl;
                    cout<<"您还有 "<<c.shift(10,x=0)<<" 枚金币"<<endl;}
                else {
                        cout<<"平局"<<endl;
                        cout<<"您还有 "<<c.shift(0,x=-1)<<" 枚金币"<<endl;}
     }
    else if(a<0&&b>=0)
           {cout<<"您爆牌了,输了20枚金币"<<endl;
            cout<<"您还有 "<<c.shift(20,x=0)<<" 枚金币"<<endl;}
        else if(a>=0&&b<0)
              {cout<<"电脑爆牌了您赢了20枚金币"<<endl;
               cout<<"您还有 "<<c.shift(20,x=1)<<" 枚金币"<<endl;}
           else
            {
            cout<<"平局"<<endl;
            cout<<"您还有 "<<c.shift(0,x=-1)<<" 枚金币"<<endl;}
}
//欢迎界面
void welcome()
{
 cout<<"                #########################"<<endl;
 cout<<"                #                       #"<<endl;
 cout<<"                #          21点         #"<<endl;
 cout<<"                #         欢迎您        #"<<endl;
 cout<<"                #                       #"<<endl;
 cout<<"                #########################"<<endl;
 cout<<"游戏规则:"<<endl;
 cout<<"在游戏中,每个玩家都争取拿到最接近21点的牌,<可以多次要牌,然后点数累加>;但是不能超过21点,超过为“爆牌”即失败,只有最接近21点的人才有可能得到胜利。"<<endl;
 cout<<"游戏开始:";
}
int money::shift(int a,int b)
{if(b==1)
    M+=a;
else if(b==0)
    M-=a;
return M;
}
int main()
{point21 D;char i;
 welcome();
do
{
D.Sru();
D.Cli();
D.display();
if(D.display()==0)break;
cout<<"您要在来一局吗? 按1键继续,退出请按q。"<<endl;
cin>>i;
}
while(int(i)!='q');
cout<<"欢迎再来"<<endl;
return 0;
}

 2006-07-24 23:54
	    2006-07-24 23:54
  斑竹你好:
    谈点题外话,学了C++也有段时间了,想出去找点这方面的工作。
我也算是这个板块的常客了,也得到斑竹得不少帮助,我想斑竹对我也有所了解了吧?所以想问问斑竹,以我目前得能力能不能到外面去找这方面得工作。
斑竹乃世外高人也,我想一定能有真知灼见得。
[此贴子已经被作者于2006-7-25 0:05:13编辑过]

 2006-07-24 23:59
	    2006-07-24 23:59
   2006-07-26 12:10
	    2006-07-26 12:10
  斑竹你好:
    谈点题外话,学了C++也有段时间了,想出去找点这方面的工作。
我也算是这个板块的常客了,也得到斑竹得不少帮助,我想斑竹对我也有所了解了吧?所以想问问斑竹,以我目前得能力能不能到外面去找这方面得工作。
斑竹乃世外高人也,我想一定能有真知灼见得。
似乎是在对我说话吧?
   实话给你说了吧,我也是菜鸟,还不是一般的菜,我接触编程的年龄就是我在这个论坛的“年龄”。
 2006-07-26 12:52
	    2006-07-26 12:52
   2006-07-26 14:39
	    2006-07-26 14:39
  
 
										
					
	
 2006-07-27 15:11
	    2006-07-27 15:11
   2006-07-27 19:29
	    2006-07-27 19:29
  但是我发现我没看的 书和工作中具体的怎么做好像 有很大的区别啊
我发现我学的都只是语法上的东西例如老谭的书,但工作中好像全是什么数据库连接啊什么的真是一头雾水啊
[此贴子已经被作者于2006-7-29 16:18:07编辑过]

 2006-07-28 13:17
	    2006-07-28 13:17
  #include <iostream>
#include <stdlib.h>
#include <ctime>
using namespace std;
//金钱类
class money
{public:
    money(){M=50;}
    int shift(int a,int b);
private:
   int M;
};
//21点类
class point21
{public:
    void Sru();
    void Cli();
    int display();
private:
    int a;
    int b;
    money c;
};
//21点程序
void point21::Sru()
{int i=1,j=0; char c;
b=0;a=0;
srand(time(0));
while(j==0)
{if(b<13)
    {if(rand()%6<4)
        b+=(rand()%9+1);}
else if(b>=13&&b<=21)
    {if(rand()%6<2)
        b+=(rand()%9+1);}
if(b>18)j=1;
}
while(i==1)
{
    cout<<"要牌请按Y/y,亮牌请按T/t: "<<endl;
    cin>>c;
    if(c=='y'||c=='Y')
    {a+=(rand()%9+1);cout<<"您的牌点是:"<<a<<endl;}
    if(c=='T'||c=='t')
        i=0;}
}
void point21::Cli()
{cout<<"您的牌点是:"<<a<<"    "<<"电脑的牌点是:"<<b<<endl;
a=21-a;
b=21-b;
}
int point21::display()
{int x;
if(a>=0&&b>=0)
     {if(a<b)
        {
            cout<<"您胜利赢了10枚金币"<<endl;
            cout<<"您还有 "<<c.shift(10,x=1)<<" 枚金币"<<endl;}
            else if(a>b)
                {
                    cout<<"您输了10枚金币"<<endl;
                    cout<<"您还有 "<<c.shift(10,x=0)<<" 枚金币"<<endl;}
                else {
                        cout<<"平局"<<endl;
                        cout<<"您还有 "<<c.shift(0,x=-1)<<" 枚金币"<<endl;}
     }
    else if(a<0&&b>=0)
           {cout<<"您爆牌了,输了20枚金币"<<endl;
            cout<<"您还有 "<<c.shift(20,x=0)<<" 枚金币"<<endl;}
        else if(a>=0&&b<0)
              {cout<<"电脑爆牌了您赢了20枚金币"<<endl;
               cout<<"您还有 "<<c.shift(20,x=1)<<" 枚金币"<<endl;}
           else
            {
            cout<<"平局"<<endl;
            cout<<"您还有 "<<c.shift(0,x=-1)<<" 枚金币"<<endl;}
}
//欢迎界面
void welcome()
{
cout<<"                #########################"<<endl;
cout<<"                #                       #"<<endl;
cout<<"                #          21点         #"<<endl;
cout<<"                #         欢迎您        #"<<endl;
cout<<"                #                       #"<<endl;
cout<<"                #########################"<<endl;
cout<<"游戏规则:"<<endl;
cout<<"在游戏中,每个玩家都争取拿到最接近21点的牌,<可以多次要牌,然后点数累加>;但是不能超过21点,超过为“爆牌”即失败,只有最接近21点的人才有可能得到胜利。"<<endl;
cout<<"游戏开始:";
}
int money::shift(int a,int b)
{if(b==1)
    M+=a;
else if(b==0)
    M-=a;
return M;
}
int main()
{point21 D;char i;
welcome();
do
{
D.Sru();
D.Cli();
D.display();
if(D.display()==0)break;
cout<<"您要在来一局吗? 按1键继续,退出请按q。"<<endl;
cin>>i;
}
while(int(i)!='q');
cout<<"欢迎再来"<<endl;
return 0;
}

 2006-09-29 19:03
	    2006-09-29 19:03