#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 20
typedef int Status;
typedef int ElemType;
typedef struct{
ElemType data[MAXSIZE];
int length;
}SqList;
Status InitList_Sq(SqList &L){
//构造一个空的线性表L
int *p = L.data;
p= (ElemType *)malloc(MAXSIZE * sizeof(ElemType));
if(! L.elem)exit(0);
L.length = 0;
return 1;
}
Status ListInsert_Sq(SqList &L,int i,ElemType e){
//在顺序线性表L中第i个位置之前插入新的元素e
L.data[i-1] = e;
L.length++;
return 1;
}
Status GetElem(SqList L,int i,ElemType &e){
//得到第i个位置的元素,并赋值给e
e=L.data[i-1];
return 1;
}
void main(){
SqList L;
InitList_Sq(L);
ListInsert_Sq(L,1,3);
ElemType e = 0;
GetElem(L,1,e);
printf("%d\n",e);
}
04-23
04-30
04-30
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交