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

📄 avltreemain.cpp

📁 本代码演示了平衡排序二叉树的实现
💻 CPP
字号:
#include"BNode.h"
#include"auto.h"
#include"quatemion.h"
#include"strtree.h"

#include<string.h>
#include<iostream>
#include<fstream>
#include<iostream.h>
void commands(){
//下面代码为屏幕编辑二叉树
	OperationC opt(OperationC::opb);
	BTreeText at;
	auto_ptr<BNode> subtree;
	auto_ptr<CNode> cp(new CNode);
	at.setPhoto(cp.get());
	std::string str;
	char count[40];
	int  c;
	bool exitf=false;
	while(!exitf){
		std::cout<<"?>";
		std::cin>>str;
		if(str=="quit"){
			exitf=true;
		}else if(str=="exit"){
			exitf=true;
		}else if (str=="add"){
			std::cin>>str;
			at.the_key=str;
			std::cin>>count;
			c=atoi(count);
			cp->setcount(c);
			if(opt.Avltin(at))std::cout<<"successful"<<std::endl;
			else std::cout<<"failed"<<std::endl;
		}else if (str=="del"){
			std::cin>>str;
			at.the_key=str;
			std::cin>>count;
			c=atoi(count);
			cp->setcount(c);
			if(opt.AvltOut(at))std::cout<<"successful"<<std::endl;
			else std::cout<<"failed"<<std::endl;
		}else if(str=="find"){
			std::cin>>str;
			at.the_key=str;		
			if(opt.Avltfind(at)){
				at.the_node->show("the node found:\t",std::cout);
				subtree=at.the_node->cloneAll();
				opt.in_show(subtree.get(),std::cout,"the subtree:\t");
				subtree.reset();
			}else std::cout<<"failed"<<std::endl;
		}else if(str=="show"){
			opt.Avltshow(at);
		}else if((str=="clear")||(str=="delall")){
			opt.AvltOutAll(at);
		}else{
			std::cout<<"bad command"<<std::endl;
		}
	}
}
char* add(char*str,int i,double j){
	cout<<"In function add:\t"<<str<<endl;
	return str;
}
void sub(){
	cout<<"ddas;ldkfja;sldkfas;ldkf"<<endl;
}
void main(){
	commands();
//	auto_func<char*> af((auto_func<char*>::_command)add);
//	char a[40];
//	strcpy(a,af(5,"dragon is good!"));
//	cout<<a<<endl;
//	auto_proc ap((auto_proc::_command)commands);
//	ap();
}

⌨️ 快捷键说明

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