Home > Back-end >  Long run on DEV C, table of 0 is how to return a responsibility, seek guidance
Long run on DEV C, table of 0 is how to return a responsibility, seek guidance

Time:03-24

Increasing known sequence table L orderly, write algorithm, will be inserted into the appropriate position of the linear table X, guarantee the linear table orderly,

#include TypedefintElemType; # # # defineMAXSIZE100 defineOK1 defineERROR0//define the linear table typedefstruct {ElemTypeelem [MAXSIZE]; Intlength; }SeqList;//create an empty table voidInitlist (SeqListL) {L - & gt; Length=0; }//increasing input orderly sequence table intputseqList (SeqListl, intn) {inti; for(i=0; I L - & gt; Length + 2)) {printf (" insert location not
Richard "); Return (ERROR); } the if (L - & gt; Length> 1
=MAXSIZE -{printf (" table is full can't insert "); Return (ERROR); } the for (k=L - & gt; Length; K>=I - 1; K -) L - & gt; Elem [k + 1)=L - & gt; Elem [k]. L - & gt; Elem [I]=e; L - & gt; Length; Return (OK); }//output element intOutputSeqList (SeqList * L) {inti; for(i=0; Ilength; I++) printf (" % d, "and L - & gt; Length++); Return (L - & gt; Elem [I]); }//main program intmain () {ints, c; SeqListL; Initlist (& amp; L); Printf (" please enter the sequence table length: "); The scanf (" % d ", & amp; S); Printf (" please input increasing sequence table: "); PutseqList (& amp; L, s); Printf (" table for % d \ n "long, L.l ength); Printf (" please enter to insert elements: "); The scanf (" % d ", & amp; C); InsList (& amp; L, PositionList (& amp; L, c), c); OutputSeqList (& amp; L); printf("\n"); }

  • Related