博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PAT A1043
阅读量:6938 次
发布时间:2019-06-27

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

clipboard.png

简单的不用考虑平衡的二叉查询树;
我发现我有读题障碍症。。。

#include
#include
#include
#include
using namespace std;using std::vector;int n;struct node{ int data; node* lchild; node* rchild;};vector
input;vector
inorder_;vector
change_inorder_;vector
postorder_;vector
change_postorder_;node* newNode(int x){ node* root=new node; root->lchild=NULL; root->data=x; root->rchild=NULL; return root;}void insert(node* &root,int x){ if(root==NULL){ root=newNode(x); return ; } if(x
data){ insert(root->lchild,x); }else{ insert(root->rchild,x); } return ;}void inorder(node* root,vector
& vi){ if(root==NULL) return; vi.push_back(root->data); inorder(root->lchild,vi); inorder(root->rchild,vi);}void postorder_change(node* root){ if(root==NULL) return; postorder_change(root->lchild); postorder_change(root->rchild); swap(root->lchild,root->rchild);}void postorder(node* root,vector
& vi){ if(root==NULL) return; postorder(root->lchild,vi); postorder(root->rchild,vi); vi.push_back(root->data);}int main(){ int mem; node* root=NULL; scanf("%d",&n); for(int i=0;i

转载地址:http://czsnl.baihongyu.com/

你可能感兴趣的文章
完善(用户调研反馈+自评+典型用户与场景)
查看>>
elasticsearch接口开发(新)
查看>>
How to configure your MyInbox webpart automatically ?
查看>>
Linux : centOS 与 Ubuntu 安装 Nginx
查看>>
Django&Admin站点&调整站点信息
查看>>
POJ2125 Destroying The Graph
查看>>
详细的App推广前的准备工作
查看>>
15年1月的每天小程序
查看>>
多选插件multiselect.js
查看>>
Mysql基本用法-存储引擎-04
查看>>
使用GregorianCalendar模拟实现查看当前月的日历
查看>>
linux下的视频音频播放器终极解决方案
查看>>
让程序跨进网络时代——使用C语言获取百度源代码
查看>>
egret 精简游戏项目
查看>>
第 1 章 虚拟化 - 009 - KVM 网络虚拟化基础
查看>>
OpenJDK 源代码阅读之 BitSet
查看>>
观察者模式
查看>>
写给产品经理的技术书:客户端、服务端和交互相关技术
查看>>
Here's to the crazy ones.
查看>>
react router browserhistory 关于 Nginx配置
查看>>