码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-01-16 22:47:58      阅读:471      评论:0      收藏:0      [点我收藏+]

标签:span   one   efi   als   线性表   线性   erro   style   sql   

写的不标准,改了改勉强过了。。

#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;
}

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

标签:span   one   efi   als   线性表   线性   erro   style   sql   

原文地址:http://www.cnblogs.com/LuRenJiang/p/6291112.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!