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

📄 test.cpp

📁 一些查找的程序
💻 CPP
字号:
#include<iostream>
using namespace std;
#include"BST.h"


int Findsort(int sort,BSTNode<int> *p);


int main()
{   
	const int array = 100;
	int a[array];
	int suc = 1;
	int b = 0;
	cout << "input an intergal array,end with -1" << endl;
	for(int i = 0;b != -1; i++)
	{   
		cin >> a[i];
		b = a[i];
	    
	}
	BinarySearchTree<int> test;
	for(int n = 0; a[n] != -1; n++)
	{   
		suc = test.Insert(a[n]);
		
	}
	test.SetInfo(test.Root);
	test.GetInfo(test.Root);
	cout << "please int the number is rising sort" << endl;
	int num = 0;//输入队列值
	cin >> num;
	int result = 0;//输出结果
	result = Findsort(num,test.Root);
	cout << "the " << num << "th smallest number in the array is: " << result << endl;
	cout << "please input an intergal to insert" << endl;
	int x = 0;
	cin >> x;
	suc = test.Insert(x);
	
	return 0;

}


int Findsort(int sort,BSTNode<int> *p)
{
	if(sort == p->info +1)
		return p->data;
	else if(sort < p->info+ 1)
		return (Findsort(sort,p->left));
	else 
        return (Findsort((sort-p->info-1),p->right));

}

⌨️ 快捷键说明

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