Sequential storage of linear tables and sequential storage of linear tables

Source: Internet
Author: User

Sequential storage of linear tables and sequential storage of linear tables
# Include <iostream>
# Include <cstdio>
# Include <cmath>
# Include <cstring>
# Include <algorithm>
# Include <vector>
# Include <queue>
# Include <stdlib. h>
# Include <string. h>
# Include <iomanip>
# Define N 500010
# Define INF 10000000
# Define LL long
# Define eps 10E-9
# Define mem (a) memset (a, 0, sizeof ())
# Define w (a) while ()
# Define s (a) scanf ("% d", &)
# Define ss (a, B) scanf ("% d", & a, & B)
# Define sss (a, B, c) scanf ("% lld", & a, & B, & c)
# Define maxn9999
# Define MAXSIZE 10
# Define DLEN 4
# Define maxn9999
# Define MAXSIZE 10
# Define DLEN 4
Using namespace std;
Struct mylist // only one struct is similar to an array ..
{
Int data [MAXN]; // store data
Int length; // The number of data records.
} Node;
Void myinsert (int pos, int cnt)
{
For (int I = node. length; I> = pos; I --)
{
Node. data [I + 1] = node. data [I];
}
Node. data [pos] = cnt;
Node. length ++;
Cout <"success! "<Endl;
For (int I = 1; I <= node. length; I ++)
{
Cout <node. data [I] <"";
}
Cout <endl;
}
Void mydelete (int pos)
{
For (int I = pos; I <node. length; I ++)
{
Node. data [I] = node. data [I + 1];
}
Node. length --;
Cout <"success! "<Endl;
For (int I = 1; I <= node. length; I ++)
{
Cout <node. data [I] <"";
}
Cout <endl;
}
Void myquery (int pos)
{
Cout <node. data [pos] <endl;
}
Int main ()
{
Int num;
Printf ("input the length of data \ n ");
Cin> num;
Node. length = num;
Cout <"input all the data" <endl;
For (int I = 1; I <= num; I ++)
{
Cin> node. data [I];
}
Int pos, cnt;
Cout <"input the postion and data of insert" <endl;
Cin> pos> cnt;
Myinsert (pos, cnt );
Cout <"input the postion of the data you want to dalete" <endl;
Cin> pos;
Mydelete (pos );
Cout <"input the postion of the data you want to query" <endl;
Cin> pos;
Myquery (pos );
Return 0;
}

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.