📄 sqlist_main.cpp
字号:
#include <stdlib.h>
#include <time.h>
#include <iostream.h>
#include "SQList.h"
void visit(int &);
void main()
{ //声明List对象La,Lb,类参数List_entry用<int>实例化
List<int> La; int n; time_t t; srand((unsigned)time(&t)); //初始化随时间变化的随机数种子
cout<<"Please input Size of A (<=30)";
cin>>n;
for(int i=0; i<n; i++) //用随机数发生器产生n个线性表元素
La.insert(La.size(),rand() % 97); // 产生0-97间的随机整数插入表尾
cout<<"\n A = { "; // 输出线性表A的头
La.traverse(visit); cout<<" }\n";
int k,e;
cout<<"Please input remove loc "; cin>>k;
La.remove(k,e);
cout<<"\n A = { "; // 输出线性表A的头
La.traverse(visit); cout<<" }\n remove ="<< e<< endl;
for(i=0; i< La.size(); i++)
{ La.retrieve(i,k); cout<<k<<' '; }
cout<<endl;
}
void visit(int &i)
{ cout<<i<<' '; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -