第三周 项目一 顺序表的基本运算
2017-12-26 20:10
260 查看
#include <iostream> #include <malloc.h> using namespace std; typedef int kong; typedef struct { int data[50]; int length; }sqlist; void Createlist(sqlist*&L,kong a[],int n);//建立一个空的线性表 void DispList(sqlist *L);//顺序输出线性表的内容。 int ListEmpty(sqlist *L);//判断线性表是否为空; int main() { sqlist *sq; kong b[5]={1,2,3,4,5}; Createlist(sq,b,5); DispList(sq); return 0; } void Createlist(sqlist*&L,kong a[],int n) { int x; L=(sqlist *)malloc(sizeof(sqlist)); for(x=0;x<n;x++) L->data[x]=a[x]; L->length=n; } void DispList(sqlist *L) { int x; if(ListEmpty(L)==1) return; for(x=0;x<L->length;x++) cout<<L->data[x]; cout<<endl; } int ListEmpty(sqlist *L) { return (L->length==0); }运行结果:
知识点总结:
实现顺序表基本运算,运用了viod和int函数,又用指针和链表。
相关文章推荐
- 第三周项目1-顺序表的基本运算(1)
- 第三周实践项目-顺序表的基本运算
- 第三周 --项目一【顺序表的基本运算一】
- 第三周-项目1-顺序表的基本运算
- 第三周项目1—顺序表的基本运算
- 第三周-项目1-顺序表的基本运算
- 第三周项目1-顺序表的基本运算
- 第三周—项目1顺序表的基本运算
- 第三周项目(1)-顺序表的基本运算
- 第三周项目-1 顺序表的基本运算
- 第三周【项目1 - 顺序表的基本运算】
- 【第三周 项目1-顺序表的基本运算】
- 数据结构第三周项目一-顺序表的基本运算
- 第三周项目1、项目2: 顺序表的基本运算、建立“顺序表”算法库
- 第三周项目1 顺序表的基本运算(增加四个函数)
- 第三周项目1--顺序表的基本运算(1)
- 第三周【项目1 - 顺序表的基本运算】
- 第三周 项目1 顺序表的基本运算
- 第三周实践项目1--顺序表的基本运算(3)插入.删除数据,初始化.销毁线性表
- 第三周-项目1 - 顺序表的基本运算