Lab 1 -- sequence table routine

Source: Internet
Author: User
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 ;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.