⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.cpp

📁 清华大学计算机系数据结构课程教材《数据结构 用面向对象方法和C++描述》(殷人昆主编)的类库(书中程序的源代码)
💻 CPP
字号:
#include<iostream>
using namespace std;
#include "SortedList.h"

int main() {
	cout<<"输入表:"<<endl;
	SortedList<int,int> lst;
	lst.build();
	cout<<endl;
	lst.show();
	cout<<endl;
	cout<<"搜索元素:";
	int x;
	cin>>x;
	int r=lst.Search(x);
	if(r!=0)
		cout<<"元素位置:"<<r<<endl;
	else
		cout<<"无此元素"<<endl;

	cout<<endl;
	cout<<"搜索元素:";
	x;
	cin>>x;
	r=lst.BinarySearch(x,1,lst.Length());
	if(r!=0)
		cout<<"元素位置:"<<r<<endl;
	else
		cout<<"无此元素"<<endl;
	cout<<endl;
	cout<<"搜索元素:";
	cin>>x;
	r=lst.BinarySearch(x);
	if(r!=0)
		cout<<"元素位置:"<<r<<endl;
	else
		cout<<"无此元素"<<endl;
	cout<<"测试完毕"<<endl;

	while(1)//为了在类库说明文档中便于观察,加入这一句
		cout<<"";
	return 0;
}

/*
输入示例:
输入表:
请输入元素个数:4

输入元素值:1

输入元素值:2

输入元素值:3

输入元素值:4


表为:
1  2  3  4

搜索元素:1
元素位置:1

搜索元素:2
元素位置:2

搜索元素:3
元素位置:3
测试完毕

*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -