Bootstrap

c语言建立顺序表 存储并输出,c语言:顺序表的实现(一) 创建,插入,删除,查找,输出等基本操作实现...

#include

#include

#define LIST_INIT_SIZE 100

#define LIST_INCREMENT 10

using namespace std;

struct Sqlist{

long *elem, *newlist;

int Length;

int listsize;

};

void Error(char *s)

{

cout << s << endl;

exit(1);

}

void InitList_Sq(Sqlist &L) //创建含有若干个数据元素的顺序表

{

L.elem = new long[LIST_INIT_SIZE];

if (!L.elem)

Error("Overflow!");

L.Length = 0;

L.listsize = LIST_INIT_SIZE;

}

void Create_Sq(Sqlist *L)

{

int i, num;

cout << "请输入顺序表元素个数:";

cin >> num;

cout << "请输入数据元素:";

for (i = 0; i

{

cin >> L->elem[i];

L->Length++;

}

cout <

;