Home > Back-end >  Great god save c + +
Great god save c + +

Time:05-06

# include
# include
using namespace std;
# define ok 0
# define the error - 1
# define Max 9
Typedef char typeelem;
Typedef int the status;
Typedef struct no
{
Typeelem * elem;
Int len.
} sqlist;
The status initlist (sqlist & amp; L);//constructs an empty line linear table
The status shuzhi (sqlist & amp; L);
The status quezhi (sqlist & amp; L, typeelem & amp; e);
The status bianli sqlist (L);
The status listinsert (sqlist& L, typeelem & amp; A);
//the status clearlist (sqlist & amp; L, typeelem & amp; B);
The status dstroylist (sqlist & amp; L);
//the status listempt sqlist (L);
Int main ()
{
Sqlist L;
Typeelem e;
Typeelem a;
Initlist (L);
Shuzhi (L);
Quezhi (L, e);
Bianli (L);
Cout & lt; Cout & lt; <"\ b please enter to insert the value of a" & lt; Cin & gt;> a;
Listinsert (L, a);
Bianli (L);
//clearlist (L, b);
Dstroylist (L);//bianli (L);
Return ok;
}
The status initlist (sqlist & amp; L)
{
L.e lem=new typeelem (Max);
if(! L.e lem)
{
Cout & lt; <"\ b splitting failure" & lt; Return the error;
}
The else
{L.l en=Max - 1; }
}
The status shuzhi (sqlist & amp; L)
{
int i;
For (I=1; i<=L.l en; I++)
{
Cin & gt;> L.e lem [I];
}
Return ok;
}
The status quezhi (sqlist & amp; L, typeelem & amp; E)
{
int i;
Cout & lt; <"\ b, please enter the element number to take out a few 0 (Max - 1)" & lt; Cin & gt;> i;
E=L.e lem [I];
Return ok;
}
The status bianli sqlist (L)
{
Cout & lt; <"\ b now began to traverse the entire linear table" & lt; int i;
if(! L.e lem)
{
Cout & lt; <"Table" empty & lt; Return the error;
}
The else
For (I=1; i<=L.l en; I++)
{
Cout & lt; }
Return ok;
}
The status listinsert (sqlist & amp; L, typeelem & amp; A)//insert element operation
{
int i;
int j;
Cin & gt;> i;
If (i<1 | | i> L.l en + 1)
{
Cout & lt; <"\ b input does not exist" & lt; Return the error;
}
Cout & lt; <"\ b please enter to insert elements" & lt; For (j=L.l en + 1; J> i; J -)//the original array space allocation of the nine space, only eight
L.e lem [j]=L.e lem [j - 1); J/* this team can be understood as a pointer to the same thing, assuming that I want to be in a 6 insert element array space, need the sixth space is empty, the 6
Space after the value in turn back (including 6) */
L.e lem [I]=a;
L.l en++;
Return ok;
}
The status dstroylist (sqlist & amp; L)
{
If (L.e lem)
{
The delete [] (L.e lem);
L.e lem=NULL;
L.l en=0;
Return ok;
}
The else {
Cout & lt; <"Table does not exist" & lt; Return the error;
}
}

/* the status clearlist (sqlist & amp; L, typeelem & amp; B)//clear the order table
{
L.e lem=NULL;//is array up space, keep Pointers to empty table only, make the space array is empty
Return ok;
} */
O great god answer why destroylist function will delete the trace/breakpoint trap wrong

CodePudding user response:

Reference:
 # include 
# include
using namespace std;
# define ok 0
# define the error - 1
# define Max 9
Typedef char typeelem;
Typedef int the status;

Typedef struct no
{
Typeelem * elem;
Int len.
} sqlist;

The status initlist (sqlist & amp; L);//constructs an empty line linear table
The status shuzhi (sqlist & amp; L);
The status quezhi (sqlist & amp; L, typeelem & amp; e);
The status bianli sqlist (L);
The status listinsert (sqlist& L, typeelem a);
//the status clearlist (sqlist & amp; L, typeelem & amp; B);
The status dstroylist (sqlist & amp; L);
//the status listempt sqlist (L);
Int main ()
{
Sqlist L;
Typeelem e;
Typeelem a;
Initlist (L);
Shuzhi (L);
Quezhi (L, e);
Cout & lt;
Bianli (L);

Cout & lt; <"\ b please enter to insert the value of a" & lt; Cin & gt;> a;
Listinsert (L, a);
Bianli (L);

//clearlist (L, b);
Dstroylist (L);//bianli (L);

Return ok;
}
The status initlist (sqlist & amp; L)
{
L.e lem=new typeelem (Max);
if(! L.e lem)
{
Cout & lt; <"\ b splitting failure" & lt; Return the error;
}
The else
{L.l en=Max - 1; }
}
The status shuzhi (sqlist & amp; L)
{
int i;
for (i=0; i<=L.l en - 1; I++)
{
Cin & gt;> L.e lem [I];
}
Return ok;
}
The status quezhi (sqlist & amp; L, typeelem & amp; E)
{
int i;
Cout & lt; <"\ b 1 -" please enter the element number to take out a few Cin & gt;> i;
If (i<1 | | i> L.l en)
{
Cout & lt; <"\ b input does not exist" & lt; Return the error;
}
E=L.e lem [I - 1);
Return ok;
}
The status bianli sqlist (L)
{
Cout & lt; <"\ b now began to traverse the entire linear table" & lt; int i;
if(! L.e lem)
{
Cout & lt; <"Table" empty & lt; Return the error;
}
The else
for (i=0; i<=L.l en - 1; I++)
{
Cout & lt;
  • Related