博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdoj-3791-二叉搜索树(二叉搜索树模板题)
阅读量:4553 次
发布时间:2019-06-08

本文共 1309 字,大约阅读时间需要 4 分钟。

#include 
#include
#include
using namespace std;typedef int ElemType;template
int getArrayLength(T &array) { return (sizeof(array) / sizeof(array[0]));}typedef struct node{ ElemType data; struct node *lchild, *rchild;}*BST;bool insertBST(BST &T, ElemType element) { if (T == NULL) { T = new node; T->data = element; T->lchild = T->rchild = NULL; return true; } if (T->data == element) return false; if (element< T->data) insertBST(T->lchild, element); else insertBST(T->rchild, element);}//judgeint flag;void judge(BST T1, BST T2) { if (T1 == NULL && T2 == NULL) { return ; } else if(T1->data != T2->data) {
//数据比较坑 flag = 0; return ; } else if(((T1->lchild !=NULL && T2->lchild !=NULL) || (T1->lchild ==NULL && T2->lchild ==NULL)) && ((T1->rchild !=NULL && T2->rchild !=NULL) || (T1->rchild ==NULL && T2->rchild ==NULL))) {
//需要考虑全面 judge(T1->lchild, T2->lchild); judge(T1->rchild, T2->rchild); }else flag = 0;}int main() { int t, n ,k ,x; BST tree[25]; while (scanf("%d", &t)!=EOF && t) { memset(tree, 0, sizeof(tree)); for (int i=0; i

 

转载于:https://www.cnblogs.com/evidd/p/9073954.html

你可能感兴趣的文章
php静态和抽象
查看>>
Jolt:软件业的奥斯卡
查看>>
机器学习课程笔记 (1)
查看>>
基础数据类型 格式化输出
查看>>
第九周作业
查看>>
解析大型.NET ERP系统 单据编码功能实现
查看>>
互联网创业应该如何找到创意 - RethinkDB创始人Slava Akhmechet的几点建议
查看>>
互联网技术架构给我们的启示
查看>>
APIO2007 风铃
查看>>
hbase redis mysql重要知识点总结
查看>>
取数字(dp优化)
查看>>
web app builder arcgis 自定义弹窗
查看>>
IE 跨域后COOKIE无法更新
查看>>
第六天冲刺
查看>>
Golang学习 - strconv 包
查看>>
ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path
查看>>
log4net 自定义日志级别记录多个日志
查看>>
imx6 system boot
查看>>
iOS .pch文件的使用
查看>>
idea 设置黑色背景
查看>>