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.