纸牌游戏——数据结构实训代码
实训要求:
题目十三、纸牌游戏
基本要求:
一副没有花牌(J、Q、K、A、大小王)的扑克牌,两个人进行纸牌游戏,其中一
个人为用户,另一个人为计算机;
每轮每人各发 5 张牌,各自以这 5 张牌建立二叉排序树;
由用户先出,轮流出牌,每次只能出一张并且要比别人出的大,如:用户出 3,计
算机则要出比 3 大的牌,没有则选择不出;
最先出完的人获胜。
#include <iostream>
#include<stdlib.h> // 产生随机数
#include<time.h>
#include <Windows.h>
#include <iomanip>
using namespace std;
class PlayingCards
{
private:
int card1[10][4];//标记发牌
int card2[5][2];//标记出牌
public:
int b[5];
char bhuase[5];
int c[5];
char chuase[5];
PlayingCards(){};
void yxsm(); //游戏说明
void fp();//随机发牌
void cp();//按顺序出牌,并显示
void xswj();//显示获得的牌
void xsdn();//显示获得的牌
void qk();//清空标记数组的记录
};
PlayingCards a;
typedef struct node
评论2
最新资源