#include <iostream>
#include <cstdlib>
#define MAXSIZE 20 //顺序表的最大长度
#define N 11
using namespace std;
/**
*实现顺序表的初始化和增删改查
*注意:该程序默认顺序表的第0个位置不用,元素从1开始存放
*/
typedef struct
{
int *elem; //存一个地址,动态分配空间
int lenth;
}Sqlist;
/****************顺序表初始化函数****************/
void initlist(Sqlist &l) //用引用
{
int nums[N]={
0,1,2,3,4,5,6,7,8,9,10};
l.elem = new int[MAXSIZE]; //后面要delete
if(l.elem == NULL )
{
C++数据结构-顺序表初始化及其增删改查
最新推荐文章于 2024-06-14 14:44:45 发布