还是课后习题

来源:百度知道 编辑:UC知道 时间:2024/07/08 13:12:49
下面的类应该模仿一副扑克牌,重写它的定义,使它符合风格原理。
class a( // a deck of cards
int X;thing Y1[52]; /*X is the location of the top card in the deck,Y1 lists the cards.*/ public: a()
void Shuffle(); //Shuffle randomly arranges the cards.
thing d(); //deals the top card off the deck
}

首先初始化扑克牌(构造函数中对数组元素进行附值)
shuffle将牌重新排序
d弹出顶部元素

代码片段书上都有,就不写了
shuffle可以用偷懒的方法,就是将x指向随即位置(查rand函数),然后默认下一元素是第一张牌,哈哈..虽然不合理,但可以骗骗老师...

C++阿,我还没学