有疑问??
#include<iostream>#include<stdlib.h>
#include<time.h>
using namespace std;
class Play
{
private:
char pai1;
char pai2;
char pai3;
public:
Play():pai1(0),pai2(0),pai3(0){}
void Set(int a, int b, int c=0)
{
pai1=a; pai2=b;pai3=c;
}
void Show()
{
cout<<pai1<<" "<<pai2<<" "<<pai3<<endl;
}
friend void Table(const Play &pl1,const Play &pl2,const Play &pl3,const Play &plz);
};
void swap(int &a,int &b)
{
int tem;
tem=a; a=b; b=tem;
}
void Xcards(int a[],int n)
{
srand((unsigned)time(NULL));
for(int i=n-1;i>0;i--)
{
int num=rand()%(i+1);
if(num!=i)
swap(a[num],a[i]);
else
{
do
{
num=rand()%(i+1);
}while(num!=i);
swap(a[num],a[i]);
}
}
}
void Table( Play pl1, Play pl2, Play pl3,Play plz);
int main()
{
int a[]={1,2,3,4,5,6,7,8,9,10,10,10,10,1,2,3,4,5,6,7,8,9,10,10,10,10,
1,2,3,4,5,6,7,8,9,10,10,10,10,1,2,3,4,5,6,7,8,9,10,10,10,10};
class Play p1;
class Play p2;
class Play p3;
class Play z;
Xcards(a,52); 洗牌
Table(p1,p2,p3,z); 显示桌面
int t=0;
p1.Set(a[t],a[t+1]); //分牌
t=+2;
p2.Set(a[t],a[t+1]);
t=+2;
p3.Set(a[t],a[t+1]);
t=+2;
z.Set(a[t],a[t+1]);
Table(p1,p2,p3,z); 显示桌面
return 0;
}
void Table(Play pl1, Play pl2, Play pl3,Play plz)
{
cout<<"庄家:"<<plz.Show()<<endl; //有问题,。
cout<<"玩家1:"<<pl1.Show()<<endl;
cout<<"玩家2:"<<pl2.Show()<<endl;
cout<<"玩家3:"<<pl3.Show()<<endl;
}
[此贴子已经被作者于2016-3-26 21:12编辑过]