The program realizes the creation of the linked list, the query function of the linked list
The Create () method implements the creation of sequential lists and calls the Find () method of the linked list query module
The Find () method implements a sequential list of queries
#include <stdio.h>
#define MAXSIZE 100//defines the length of an array
Defines a contiguous array sqlist
typedef struct sqlist{
int date [maxsize];
int length;
}sqlist;
See if there is a number x in the array
If there is, returns the position of the array, if not, returns 0;
int find (sqlist l,int x) {
Int J;
int k = 0;
for (j= 1; j<=l.length; ++j) {
if (X==l.date[j]) {
K= J;
}
Else
k=0;
}
return k;
}
Create an ordered list of links
An array corresponds to a pointer, and the pointer is stored in this method and cannot be
Continue to use
void Create (SqList l) {
int ll; The length of the sequential list
printf ("Length of the input list: \ n");
scanf ("%d", &ll);
L.length = ll;
Set up a sequential chain list
for (int i =1;i<= l.length; i++) {
printf ("Please enter%d numbers:", i);
scanf ("%d", &l.date[i]);
}
Find the sequential list to find out if there is a value x
In the list of sequential lists
int x;
printf ("Please enter a number x:");
scanf ("%d", &x);
Call lookup method Find ()
int k = Find (l, x);
if (k==0) {
printf ("Without this number");
}
Else
printf ("This number is in the position of the array%d\n", K);
}
int main (int argc, const char * argv[])
{
Defining a sequential array
SqList l;
Calling functions
Create (L);
printf ("Hello, world!\n");
return 0;
}