Linear table-Sequential storage structure Get Elem (l,i,*e)

Source: Internet
Author: User

Write not standard, changed to change reluctantly past.

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

Linear table-Sequential storage structure Get Elem (l,i,*e)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.