List of links is different

Source: Internet
Author: User

#include <iostream>
#include <cstdlib>
using namespace Std;

typedef int T;
Class Seqlist
{
Public
T *data;
int q[100];
int n;
int MaxSize; The maximum number of elements that a sequential table can hold.
int last; The subscript of the last element of the sequential table, with an initial value of-1.
seqlist (int sz);

void input ()//Enter the number of elements first, and then enter the value of the element sequentially.
void output ();//output all elements of a linear table.
void Insert (const t& x, int i);//Inserts an element with a value of x in the linear table.
void Remove (T & x);//Removes the first value equal to X from a linear table.
};

void Seqlist::input ()
{

cin>>n;
for (int i=0;i<n;i++)
{
cin>>data[i];
}

}
void Seqlist::output ()
{
cout<< "The Elements is:" << ' \ n ';
for (int i=0;i<n;i++)
{

cout<<data[i]<< ' \ n ';

}
}
void Seqlist::insert (const t& x, int i)
{
for (int j= (n-1); j>=i;j--)
{
DATA[J+1]=DATA[J];
}
Q[i]=x;
n=n+1;
}
void Seqlist::remove (T & x)
{
for (int j=0;j<n;j++)
{
if (data[j]==x)
{
for (int k=j;k<n-1;k++)
{
DATA[K]=DATA[K+1];
}
n=n-1;
}
}
}
seqlist::seqlist (int sz)
{
data = new T[sz];
MaxSize = sz;
last =-1;
}
int main ()
{
Seqlist myList (100);
Mylist.input ();
Mylist.output ();
int i;
for (i=0;i<5;i++)
Mylist.insert (I+10,i);
Mylist.output ();
for (i=10;i<15;i++)
Mylist.remove (i);
Mylist.output ();

return 0;

}

List of links is different

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.