#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
using namespace std;
static int k=0;
const string puke[]={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
const double puke1[]={1,2,3,4,5,6,7,8,9,10,0.5,0.5,0.5};
void sm()
{
cout<<"\t_______________________________________________________________________\n\n";
cout<<"\t游戏简介: 本游戏为人与电脑的扑克对抗,扑克“A”为分数1,“J”,“Q”\n";
cout<<"\t ,“K”各为分数0.5,游戏简称“十点半”,就是说——玩家、庄家手\n";
cout<<"\t 中各牌加起来的总分不得大于10.5分,如果谁手中的牌总分大于10.5分\n";
cout<<"\t ,为“自爆”,判为输。游戏开始庄家为各自发一张牌,庄家的牌是隐";
cout<<"\t 藏的,玩家的是显示出来的,首先是玩家根据自已牌的分数,进行要牌";
cout<<"\t ,当确定不在要牌时。轮到庄家要牌,玩家与庄家手中持牌不能超过三";
cout<<"\t 张牌,在没有“自爆”的情况下,在确定——庄家与玩家不在要牌时,\n";
cout<<"\t 把各自手中持牌的分数加起来,在比较谁的总分高,高的为赢家,否则";
cout<<"\t 为输家,相等则平局。\n\n";
cout<<"\t_______________________________________________________________________\n\n";
cout<<"\t游戏说明:\n";
cout<<"\t a.可设定你的总赌资,范围在1~1000000元,\n";
cout<<"\t\t 庄家的总赌资和你设定的一样多。"<<endl;
cout<<"\t b.每局可根据你自身的钱数来下注。"<<endl;
cout<<"\t c.要一张牌,请输入“1”。"<<endl;
cout<<"\t d.确定不在要牌,等待庄家翻牌,请输入“2”。\n"<<endl;
cout<<"\t e.退出,请输入“0”。\n"<<endl;
cout<<"\t_______________________________________________________________________\n\n";
}
void sm2()
{
cout<<"\t____________________________________________________\n";
cout<<"\t\t\t***申请游戏账号说明***\n";
cout<<"\t\ta.账号位数不得大于8位字符,可为字母或数字组合,\n";
cout<<"\t\t 也可以是单独的字母或数字,但必须以字母开头\n";
cout<<"\t\tb.游戏密码不得大于6位字符,可为字母或数字组合\n";
cout<<"\t\t ,也可以是单独的字线或数字\n";
cout<<"\t____________________________________________________\n";
}
void sm1()
{
cout<<"\t__________________________________________\n";
cout<<"\t\t\t***游戏说明***\n\n";
cout<<"\t\t1.进入游戏,请输入“1”。\n";
cout<<"\t\t2.申请帐号,请输入“2”。\n";
cout<<"\t\t3.退出,请输入“0”。\n";
cout<<"\t__________________________________________\n\n";
cout<<"请选择功能:";
}
class
{
public:
char playname[8];
char playkey[7];
}game[100]={{"gogogo","123456"}};;
class goplay
{
private:
char name[8];
char key[7];
char key1[7];
public:
int nameworng,nameworng1,f,i,keyworng;
string s;
void nscanf();
void npd();
void kscanf();
void kpd();
void kscanf1();
~goplay(){ }
};
void goplay::nscanf()
{
sm2();
cout<<"帐号:";
cin>>name;
f=strlen(name);
for(i=0;i<f;i++)
if(!(((name[i]>='a'&&name[i]<='z')||
(name[i]>='A'&&name[i]<='Z')||
(name[i]>='0'&&name[i]<='9'))&&
(name[0]>='a'&&name[0]<='z')||
(name[0]>='A'&&name[0]<='Z')))
{nameworng=1;break;}
for(i=k;i>=0;i--)
if(strcmp(game[i].playname,name)==0)
{nameworng1=1;break;}
}
void goplay::npd()
{
while(f>8||nameworng==1||nameworng1==1)
{
if(f>8)
{
cout<<"你申请的帐号大于8位字符\n";
nscanf();
}
if(nameworng==1)
{
cout<<"你的帐号含有非法字符\n";
nscanf();
}
if(nameworng1==1)
{
cout<<"你申请的账号以存在\n";
nscanf();
}
}
strcpy(game[++k].playname,name);
}
void goplay::kscanf()
{
cout<<"密码:";
cin>>key;
f=strlen(key);
for(i=0;i<f;i++)
if(!((key[i]>='a'&&key[i]<='z')||
(key[i]>='A'&&key[i]<='Z')||
(key[i]>='0'&&key[i]<='9')))
{keyworng=1;break;}
}
void goplay::kpd()
{
while(f>6||keyworng==1)
{
if(f>6)
{
cout<<"你的密码大于6位字符\n";
kscanf();
}
if(keyworng==1)
{
cout<<"你的密码含有非法字符\n";
kscanf();
}
}
}
void goplay::kscanf1()
{
cout<<"验证密码:";
cin>>key1;
while(!strcmp(key,key1)==0)
{
cout<<"密码不一致,请重设\n";
kscanf();
kpd();
cout<<"验证密码:";
cin>>key1;
}
strcpy(game[k].playkey,key);
cout<<"恭喜你,以申请成功,OY\n";
}
class comeplay
{
private:
char goname[8];
char gokey[7];
public:
int print();
~comeplay(){ }
};
int comeplay::print()
{
cout<<"帐号:";
cin>>goname;
cout<<"密码:";
cin>>gokey;
for(int i=0;i<=k;i++)
if(strcmp(game[i].playname,goname)==0&&
strcmp(game[i].playkey,gokey)==0)
return 1;
return 0;
}
class WANJIA
{
private:
string wanjia[3];
public:
static int s_w;
static double s_zongfen;
void fu();
int fen();
int su();
void show()const;
~WANJIA() { }
};
void WANJIA::fu()
{
srand(time(0));
int w=rand()%13;
wanjia[s_w++]=puke[w];
s_zongfen=s_zongfen+puke1[w];
}
int WANJIA::fen()
{
if(s_zongfen>=11)
return 1;
else
return 0;
}
int WANJIA::su()
{
if(s_w>=3)
return 1;
else
return 0;
}
void WANJIA::show() const
{
int i;
for(i=0;i<s_w;i++)
cout<<wanjia[i]<<" ";
cout<<endl;
}
int WANJIA::s_w=0;
double WANJIA::s_zongfen=0;
class DIANNAO
{
private:
string diannao[3];
public:
static int s_d;
static double s_zongfen1;
void fu();
int fen();
int su();
void show() const;
void show1() const;
~DIANNAO() { }
};
void DIANNAO::fu()
{
srand(time(0));
int d=rand()%13;
diannao[s_d++]=puke[d];
s_zongfen1=s_zongfen1+puke1[d];
}
int DIANNAO::fen()
{
if(s_zongfen1>=11)
return 1;
else
return 0;
}
int DIANNAO::su()
{
if(s_d>=3)
return 1;
else
return 0;
}
void DIANNAO::show() const
{
int j=4;
string pai1="****";
while(j>0)
{
cout<<"\t\t\t"<<pai1<<endl;
j--;
}
}
void DIANNAO::show1() const
{
int k=0;
while(k<s_d)
{
cout<<diannao[k]<<" ";
k++;
}
}
int DIANNAO::s_d=0;
double DIANNAO::s_zongfen1=0;
class PANDUAN
{
private:
int dqing,wqing,zwqing,swqing,sdqing,yaopai;
DIANNAO dian;
WANJIA wan;
public:
void fu();
void scanf();
void bijiao();
~PANDUAN() { }
};