怎么达不到把五十四个扑克打乱······
//a.husing namespace std;
class CMyImage
{
private:
int width;
int height;
char name[10];
public:
void printinfo();
void setname(char *name);
CMyImage()
{
width=0;
height=0;
}
void setname();
};
void CMyImage::setname(char *name)
{
strcpy(this->name,name);
}
void CMyImage::printinfo()
{
cout<<name<<endl;
}
// b.h
#include "a.h"
using namespace std;
class card
{
private:
CMyImage a;
int color;
int size;
public:
void setcard(int color,int size);
void printinfo();
};
void card::setcard(int color,int size)
{
CMyImage Image;
this->color=color;
this->size=size;
switch(color)
{
case 1:Image.setname("黑桃");
break;
case 2:Image.setname("红桃") ;
break;
case 3:Image.setname("梅花") ;
break;
case 4:Image.setname("方块");
break;
case 0:Image.setname("大小王");
break;
}
}
void card::printinfo()
{
a.printinfo();
}
//abc.h
#include "b.h"
class CCards
{
public:
card c;
card allcard[54];
void setallcard();
void change();
void printinfo();
};
void CCards::setallcard()
{
int p=0;
for(int i=0;i<=3;i++)
{
for(int j=0;j<13;j++)
{
allcard[p].setcard(i+1,j+1);
p++;
}
}
}
void CCards::change()
{
for(int p=0;p<65;p++)
{
int x,y;
card z;
x=rand()%53+1;
y=rand()%53+1;
z=allcard[x];
allcard[x]=allcard[y];
allcard[y]=z;
}
}
void CCards::printinfo()
{
c.printinfo();
}
//gh.cpp
#include <iostream>
#include "abc.h"
using namespace std;
void main()
{
CCards c;
c.printinfo();
}