Home > Back-end >  Data structure - order table element inverse. Compiled code is no problem, but the program does not
Data structure - order table element inverse. Compiled code is no problem, but the program does not

Time:12-14

Use of environmental DEVC++
 # include & lt; stdio.h> 
#include
# define LIST_INIT_SIZE 100
# define LISTINCREMENT 10
Typedef struct {
Char * elem.
int length;
int listsize;
} Sqlist;

Void InitList_Sq (Sqlist * L)//constructs an empty linear table
{
L - & gt; Elem=(char *) malloc (LIST_INIT_SIZE * sizeof (char));
if(! L - & gt; Elem)
{
Printf (" ERROR!" );
exit(1);
}
L - & gt; Length=0;
L - & gt; Listsize=LIST_INIT_SIZE;
}
Void inversion (Sqlist * L)
{
Char * p, * q, t=0;
P=L - & gt; Elem.
Q=L - & gt; Elem + L - & gt; Length - 1.
While (p{
T=* p;
* p=* q;
* q=t;
}
}
Int main ()
{
Sqlist * L;
int i=0;
char c;
InitList_Sq (L);
Do {
Printf (" please input a letter ('/' exit loop) : \ n ");
The scanf (" % c ", & amp; C);
If ((L - & gt; Length + 1) & gt; L - & gt; Listsize)//order form is full, to allocate space
{
L - & gt; Elem=(char *) realloc (L - & gt; Elem, (LIST_INIT_SIZE + LISTINCREMENT) * sizeof (char));
if(! L - & gt; Elem)
{
Printf (" ERROR!" );
exit(1);
}
L - & gt; Length=I;
L - & gt; Listsize=LIST_INIT_SIZE + LISTINCREMENT;
}
If ((c>='a' & amp; & C<='z') | | (c>='A' & amp; & C{
* (L - & gt; Elem=c + I);
i++;
L - & gt; Length=I;
}
The else printf (" input error! Please enter the letters! \ n ");

} while (c!='/');

If (L - & gt; Length==0) printf (" \ n input element, unable to reverse ");
Else if (L - & gt; Length==1) printf (" \ n % c there is only one element, not reverse place ", * (L - & gt; Elem));
The else {
Inversion (L);
Printf (" element inverse to: \ n ");
for(i=0; iPrintf (" % c ", * (L - & gt; Elem + I));
}
}



Application cannot run, please help modify!!!!! Look at what went wrong, thank you very much!!!!!!
  • Related