Description
Create, insert, delete, and search sequence tables
Input
The actual length of the input sequence table in the first row is N.
Input n data entries in the second row
Enter the new data to be inserted and the insert location in the third row.
Enter the location for deletion in the fourth row.
Enter the location to search for the fifth line
Output
After the first row of output is created, all data in the sequence table is separated by spaces.
After the insert operation is performed on the output in the second row, all data in the sequence table is separated by spaces.
After deleting the output in the third row, all data in the sequence table is separated by spaces.
The fourth row outputs data at the specified position.
Sample Input
611 22 33 44 55 66888 352
Sample output
11 22 33 44 55 66 11 22 888 33 44 55 66 11 22 888 33 55 66 22
Hint
Position I refers to the position I starting from the first element, corresponding to the position where the subscript in the array is the I-1
# Include <stdio. h> # define Max 100int seqlist [Max], Len; void insert (INT POs, int value) {int I; for (I = Len; I> = Pos; I --) seqlist [I + 1] = seqlist [I]; seqlist [POS] = value; Len ++;} void del (int pos) {int I; for (I = Pos; I <Len; I ++) seqlist [I] = seqlist [I + 1]; Len --;} void output () {int I; for (I = 1; I <= Len; I ++) printf ("% d", seqlist [I]); printf ("\ n") ;}int main () {int POs, i, value; scanf ("% d", & Len); for (I = 1; I <= Len; I ++) scanf ("% d ", & seqlist [I]); output (); scanf ("% d", & Value, & Pos); insert (Pos, value); output (); scanf ("% d", & Pos); del (POS); output (); scanf ("% d", & Pos); printf ("% d \ n ", seqlist [POS]); Return 0 ;}