📄 main.cpp
字号:
#include<iostream>
#include"SkipList.h"
using namespace std;
int main()
{
SkipList<int,int> skp(100000);
cout<<"请输入跳表结点个数:";
int n;
cin>>n;
int temp;
int i=0;
while(i<n)
{
cout<<"输入结点数据:"<<endl;
cin>>temp;
if(skp.Insert(temp,temp))
i++;
else
cout<<"错误,请重新输入"<<endl;
}
skp.show();
cout<<endl;
cout<<"搜索元素:";
cin>>temp;
if(skp.Search(temp,temp))
cout<<"此元素在跳表中"<<endl;
else
cout<<"此元素不在跳表中"<<endl;
cout<<endl;
cout<<"删除元素:";
cin>>temp;
if(skp.Remove(temp,temp))
{
cout<<"删除后,"<<endl;
skp.show();
}
else
cout<<"删除失败!"<<endl;
cout<<endl;
cout<<"测试完毕"<<endl;
while(1)//为了在类库说明文档中便于观察,加入这一句
cout<<"";
return 0;
}
/*
输入示例:
请输入跳表结点个数:7
输入结点数据:
1
输入结点数据:
4
输入结点数据:
2
输入结点数据:
3
输入结点数据:
7
输入结点数据:
8
输入结点数据:
9
maxLevel : 200
Levels : 2
Level 1 : head -- 1 -- 3 -- 4 -- 9 -- tail
Level 0 : head -- 1 -- 2 -- 3 -- 4 -- 7 -- 8 -- 9 -- tail
搜索元素:3
此元素在跳表中
删除元素:2
删除后,
maxLevel : 200
Levels : 2
Level 1 : head -- 1 -- 3 -- 4 -- 9 -- tail
Level 0 : head -- 1 -- 3 -- 4 -- 7 -- 8 -- 9 -- tail
测试完毕
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -