operation12InitList(L): 初始化线性表ListEmpty(L): 判断线性表是否为空 任务12345/*1.定义线性表类型的对象L。2.初始化线性表L,并输出其长度。3.判断线性表是否为空。*/ 代码实现:C123456789101112131415161718192021222324252627282930313233343536373839404142#include<stdio.h>#define OK 1#define ERROR 0#define TRUE 1#define FALSE 0#define MAXSIZE 20typedef int ElemType;//抽象数据类型,是线性表中数据元素的数据类型。typedef int Status;//抽象数据类型,是函数返回值的类型typedef struct{ ElemType data[MAXSIZE]; int length;}SqList;Status InitList(SqList L){ L.length = 0; return OK;}Status ListEmpty(SqList L){ if(L.length == 0) return TRUE; else return FALSE;}int main(){ SqList L;//定义一个顺序结构的线性表。 Status i; i = InitList(L);//初始化线性表L。 printf("L.length = %d\n",L.length);//输出线性表的长度。 i = ListEmpty(L);//判断线性表是否为空 printf("L是否为空?i=%d(1:是 0:否)\n",i);} C++12345678910111213141516171819202122232425262728293031323334353637383940414243#include<iostream>using namespace std;#define OK 1#define ERROR 0#define TRUE 1#define FALSE 0#define MAXSIZE 20typedef int ElemType;//抽象数据类型,是线性表中数据元素的数据类型。typedef int Status;//抽象数据类型,是函数返回值的类型typedef struct{ ElemType data[MAXSIZE]; int length;}SqList;Status InitList(SqList L){ L.length = 0; return OK;}Status ListEmpty(SqList L){ if(L.length == 0) return TRUE; else return FALSE;}int main(){ SqList L;//定义一个顺序结构的线性表。 Status i; i = InitList(L);//初始化线性表L。 cout<<"L.length = "<<L.length<<endl;//输出线性表的长度。 i = ListEmpty(L);//判断线性表是否为空 cout<<"L是否为空?i="<< i <<"(1:是 0:否)"<<endl;}