# Include <stdio. h> # Include <Stdlib. h> # Define Maxlength 1000 Typedef Struct { Int Total; Int Date [maxlength];} linelist; Void Showlist (linelist * List ){ Int I; If (List-> total =0 ) {Printf ( " Empty linear table \ n " ); Return ;} Printf ( " Current linear Table Status: " ); For (I = 0 ; I <list-> total; I ++ ) {Printf ( " % D \ t " , List-> Date [I]);} printf ( " \ N " );} Void Output (linelist * List) {system ( " CLS " ); Printf ( " -- Sequence table -- \ n " ); Printf ( " A.-Add node I and-insert node \ n " ); Printf ( " D.-delete node E and-exit \ n " ); Showlist (list);} linelist * Createlist () {linelist * List = (linelist *) malloc ( Sizeof (Linelist); List -> Total = 0 ; Return List ;} Void Appendnode (linelist * List, Int Val ){ If (List-> total < Maxlength) {list -> Date [list-> total] = Val; List -> Total ++ ;}} Void Insertnode (linelist * List, Int Val, Int Pos ){ Int I; If (Pos < 0 | POS> list-> Total) {printf ( " The insertion location is incorrect. " );} For (I = Pos; I <list-> total; I ++ ) {List -> Date [I + 1 ] = List-> Date [I];} List -> Date [POS] =Val; List -> Total + = 1 ;} Void Deletenode (linelist * List, Int Pos ){ If (Pos < 0 | POS> list-> Total) {printf ( " The deleted node does not exist. " );} Else { Int I; For (I = Pos; I <list-> total; I ++ ) List -> Date [I] = List-> date [I + 1 ]; List -> Total -- ;}} Void Main (){ Int Key, Pos; Char Act; linelist * Mylist =Createlist (); While ( 1 ) {Output (mylist); printf ( " Please perform the following operations: " ); Act = Getchar (); fflush (stdin ); Switch (ACT ){ Case ' A ' : Printf ( " Enter the key to add " ); Scanf ( " % D " ,& Key); appendnode (mylist, key ); Break ; Case ' I ' : Printf ( " Enter the key and POs to be inserted. " ); Scanf ( " % D " , & Key ,& Pos); insertnode (mylist, key, POS ); Break ; Case ' D ' : Printf ( " Enter the POs to delete " ); Scanf ( " % D " ,& Pos); deletenode (mylist, POS ); Break ; Case ' E ' : Exit ( 0 ); Output (mylist); fflush (stdin ); Break ; Default : Break ;}}}
An ordered table stores all elements in a linear table to a specified Continuous Bucket according to its logic ···