#include
# include & lt; Stdlib. H>
# define overflow - 1
# define ok 1
# define the error 0 typedef
Int the status; Typedef char elemtype;
Typedef struct lnode {elemtype data; Struct lnode * next; } lnode * linklist; The status initlist (linklist & amp; Initialization L) {////here to fill in the code} status listinsert (linklist & amp; L, int I elemtype e) {//into//the complete code} status listtraverse (linklist L) {//traverse//here to fill in the code} status getelem (linklist L, int I elemtype & amp; E) {////get data to fill in the code here} int locateelem (linklist, L elemtype e) {//location//here to fill in the code} status listdelete (linklist & amp; L, int I elemtype & amp; E) {//delete//here to fill in the code} status destroylist (linklist & amp; L) {//cancellation//here to fill in the code} int main () {//elemtype e; Linklist L; Int TestCase; The scanf (" % d ", & amp; The TestCase); Printf (" (1) the initial linear table L: \ n "); Initlist (L); Printf (" (2) in linear table L in turn tail insert characters a, b, c, d, e: \ n "); Listinsert (L, 1, 'a'); Listinsert (L, 2, "b"); Listinsert (L, 3, "c"); Listinsert (L, 4, 'd'); Listinsert (L, 5, 'e'); Printf (" (3) before the second position of linear table L insert character f: \ n "); Listinsert (L, 2, "f"); The switch (TestCase) {case 1://traverse printf (" (4) the output of linear table L: \ n "); Listtraverse (L); break; Case 2://element printf (" (5) the output of linear table L third element: "); Getelem (L, 3, e); Printf (" % c \ n ", e); break; Case 3://positioning printf (" (6) output element in the position of the linear table L d: % d \ n ", locateelem (L, 'd')); break; Case 4://delete, traversal (make sure to delete the effect) printf (" (7) to delete the fourth element: linear table L \ n "); Listdelete (L, 4, e); Printf (" (8) output linear table L: \ n "); Listtraverse (L); break; Comprehensive (default://traverse, access, positioning, delete, traversal) printf (" (4) the output of linear table L: \ n "); Listtraverse (L); Printf (" (5) the output of linear table L 3 elements: "); Getelem (L, 3, e); Printf (" % c \ n ", e); Printf (" (6) output element in the position of the linear table L d: % d \ n ", locateelem (L, 'd')); Printf (" (7) to delete the fourth element: linear table L \ n "); Listdelete (L, 4, e); Printf (" (8) output linear table L: \ n "); Listtraverse (L); } printf (" (9) release the linear table L, \ n "); Destroylist (L); Return ok; }
CodePudding user response:
What do you think the layout code? Compile results and operation results can dry out and see,