线性表之顺序表C++实现(2)

#include<iostream>
#include"SeqList.h"
using namespace std;
void show()
{
  cout << "---------------------------------------" << endl;
}
int main()
{
  int array[10] = {1,3,4,2,5,6,8,7,9,10};
  SeqList<int> seqList = SeqList<int>(array,10);
  cout << "顺序表为:" << endl;
  seqList.PrintSeqList();
  show();
  cout << "顺序表的长度为:" << seqList.GetLength()<< endl;
  cout << "第三个位置的元素是:" << seqList.GetElement(3) << endl;
  cout << "元素3的位置是:" << seqList.GetLocal(3) << endl;
  show();
  cout << "在第5个位置插入元素22" << endl;
  seqList.Insert(5, 22);
  cout << "顺序表为:" << endl;
  seqList.PrintSeqList();
  cout << "顺序表的长度为:" << seqList.GetLength() << endl;
  show();
  cout << "删除第5个位置的元素" << endl;
  seqList.Delete(5);
  cout << "顺序表为:" << endl;
  seqList.PrintSeqList();
  cout << "顺序表的长度为:" << seqList.GetLength() << endl;
  show();
  return 0;
}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/bb328e418885f7d49973b259e2ea7321.html