线性表—顺序存储结构 Get Elem(L,i,*e)

我只是默写,不过也改了改勉强过了。。

#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 20
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALS 0
typedef  int Status;
typedef int ElemType;
typedef struct
    {
        ElemType data[MAXSIZE];
        int length;
    }SqList;
Status GetElem(SqList L,int i,ElemType *e);
int main()
{

    SqList l;
    l.length=10;
    int j,e;
    for(j=0;j<l.length;j++)
    {
        l.data[j]=j+1;
    }

    printf("%d ",GetElem(l,3,&e));
    printf("%d\n",e);
    return 0;
}
Status GetElem(SqList L,int i,ElemType *e)
{
    if(i<1||i>L.length||L.length==0)
    {
        return ERROR;
    }
    *e=L.data[i-1];

    return OK;
}

 

posted @ 2017-01-16 21:36  路人姜。  阅读(1066)  评论(0编辑  收藏  举报