Home > Back-end >  C + + linear sequence table error
C + + linear sequence table error

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;
} */
The destroy function operation delete displays trace/breakpoint trap errors, hope to have a great god answers

CodePudding user response:

Possible space open Max and use does not match (note that when using, do not cross), an unknown error will occur and, or Trace/breakpoint trap anomalies

CodePudding user response:

reference 1st floor focuslight response:
possible space open Max and use does not match (note that when using do not cross, unknown error will occur and, or Trace/breakpoint trap anomaly

I use breakpoint check found running to destroy function l. elem address and began opening address is different, this how to return a responsibility
  • Related