#include
using namespace std;
# define ok 0
# define the error - 1
# define Max 6
Typedef char typeelem;
Typedef int the status;
Typedef struct no
{
Struct no * next;
Typeelem data;
} noe, * noa;
Typedef struct noc
{
Noa tail and head;
Int leng.
} sqlist;
The status initlist (sqlist & amp; L);//create an empty chain linear table
The status shuzhi (sqlist & amp; L);//to create the Max size chain table table
The status traverselist sqlist (L);//to traverse the chain table
The status getelem (sqlist L, int I);//in the chain table will remove the element I
The status locateelem (sqlist L, typeelem e, int c);//in the chain in the table to find the value of e values of the nodes and for the first c
The status listinsert (sqlist & amp; Int L, d, typeelem a);//chain table insert value
The status listdelete (sqlist & amp; L, typeelem b);//delete the value of b node
Int main ()
{
Sqlist L;
Int I, d, c;
Typeelem e, a, b;
Initlist (L);
Cout & lt; <"Put Max=" & lt;
Cout & lt; <"Traverselist" & lt;
Cout & lt; <"Put the I from 1 -" & lt;
Getelem (L, I);
Cout & lt; <"Seek number c and elem e" & lt;
Locateelem (L, e, c);
Return ok;
}
The status initlist (sqlist & amp; L)
{
L.h ead=new noe [1].
if(! L.h ead)
{
Cout & lt; <" \ bfailure to open up space "& lt;
}
The else
L.t ail=L.h ead;
L.l eng=0;
}
The status shuzhi (sqlist & amp; L)
{
Noa q;
L.l eng=Max;
For (int I=0; I & lt; L.l eng; I++)
{
Q=new noe [1].
if (! Q)
{
Cout & lt; <"Failure to open up space" & lt;
}
cin> Q - & gt; The data;
L.t ail - & gt; Next=q;
L.t ail=q;
Q - & gt; Next=NULL;
}
Return ok;
}
The status traverselist sqlist (L)
{
Noa p;
P=L.h ead - & gt; Next;
For (int I=0; I & lt; L.l eng; I++)
{
Cout & lt; P=p - & gt; Next;
}
Return ok;
}
The status getelem (sqlist L, int I)
{
int j;
Noa q=L.h ead;
If (max{
Cout & lt; <"I is the error" & lt;
}
The else
for (j=1; j <=I; J++)
{
Q=q - & gt; Next;
}
Cout & lt; Return ok;
}
The status locateelem (sqlist L, typeelem e, int c)
{
C=1;
Noa q=L.h ead - & gt; Next;
While (q - & gt; The data!=e)
{
Q=q - & gt; Next;
c++;
}
If (c & gt; L.l eng)
{
Cout & lt;
}
The else
{
Cout & lt; <"The potition is" & lt;
}
Old folks, I want to consult in the locateelem function I wrote when I input the value of the linear table: no, I want to output the if (c & gt; L.l eng)
{
Cout & lt;
} code how
CodePudding user response:
Modify comments, for your reference:# include
#include
using namespace std;
# define ok 0
# define the error - 1
# define Max 6
Typedef char typeelem;
Typedef int the status;
Typedef struct no
{
Struct no * next;
Typeelem data;
} noe, * noa;
Typedef struct noc
{
Noa tail and head;
Int leng.
} sqlist;
The status initlist (sqlist & amp; L);//create an empty chain linear table
The status shuzhi (sqlist & amp; L);//to create the Max size chain table table
The status traverselist sqlist (L);//to traverse the chain table
The status getelem (sqlist L, int I);//in the chain table will remove the element I
The status locateelem (sqlist L, typeelem e, int c);//in the chain in the table to find the value of e values of the nodes and for the first c
The status listinsert (sqlist & amp; Int L, d, typeelem a);//chain table insert value
The status listdelete (sqlist & amp; L, typeelem b);//delete the value of b node
Int main ()
{
Sqlist L;
Int I, d, c;
Typeelem e, a, b;
Initlist (L);
Cout & lt; <"Put Max=" & lt;Shuzhi (L);
Cout & lt; <"Traverselist" & lt;Traverselist (L);
Cout & lt; <"Put the I from 1 -" & lt;cin> i;
Getelem (L, I);
Cout & lt; <"Seek number c and elem e" & lt;cin> e;
Locateelem (L, e, c);
Return ok;
}
The status initlist (sqlist & amp; L)
{
L.h ead=new noe [1].
if(! L.h ead)
{
Cout & lt; <" \ bfailure to open up space "& lt;Return the error;
}
The else
L.t ail=L.h ead;
L.l eng=0;
}
The status shuzhi (sqlist & amp; L)
{
Noa q;
L.l eng=Max;
For (int I=0; I & lt; L.l eng; I++)
{
Q=new noe [1].
if (! Q)
{
Cout & lt; <"Failure to open up space" & lt;Return the error;
}
cin> Q - & gt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull