纸牌游戏
来源:百度知道 编辑:UC知道 时间:2024/05/24 03:48:07
#include "iostream.h"
#include "stdlib.h"
#define OK 1
#define ERROR 0
#define LIST_INIT_SIZE 100 //线性表存储空间的初始分配量
#define LISTINCREMENT 10 //线性表存储空间的分配增量
typedef int Status;
typedef int ElemType;
typedef struct{
ElemType *elem; //存储空间基址
int *data;
int length; //当前长度
int listsize; //当前分配的存储容量
}SqList;
Status InitList_Sq(SqList &L) {
// 算法2.3
// 构造一个空的线性表L。
L.elem = (ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
if (!L.elem) return OK; // 存储分配失败
L.data = (int *)malloc(LIST_INIT_SIZE*sizeof(int));
if (!L.data) return OK; // 存储分配失败
L.length = 0; // 空表长度为0
L.listsize = LIST_INIT_SIZE; // 初始存储容量
return OK;
} // InitList_Sq
Status ListPrint_Sq(SqList L) { // 补充算法
//显示线性表中所有数据
for(int i=1;i<=L.length;i++)
{ if (L.da