hdu 3999 The order of a Tree
来源:互联网 发布:警服照试穿软件 编辑:程序博客网 时间:2024/05/19 18:40
#include <iostream>#include <stdlib.h>using namespace std;int flag;typedef struct BSTNode{int value;struct BSTNode *left,*right;}BSTNode,*BSTree;void CreatTree(BSTree &T,int temp)///Creat的时候一定是&BiTree{if(T==NULL){ T=(BSTree)malloc(sizeof(BSTNode)); T->value=temp; T->left=T->right=NULL;}else if(temp<T->value)CreatTree(T->left,temp);else CreatTree(T->right,temp);}void PreBSTree(BSTree T){if(T!=NULL){ if(flag==0) { cout<<T->value; flag=1; } else cout<<" "<<T->value; PreBSTree(T->left); PreBSTree(T->right); }}int main(){ int n,x; while(cin>>n) { BSTree root=NULL; for(int i=0;i<n;i++) { cin>>x; CreatTree(root,x); } flag=0; PreBSTree(root); cout<<endl; }return 0;}二叉搜索树建树,然后先序输出。
阅读全文
0 0
- hdu 3999The order of a Tree
- Hdu 3999 - The order of a Tree
- HDU 3999 The order of a Tree
- hdu 3999:The order of a Tree
- hdu 3999The order of a Tree
- hdu 3999 The order of a Tree
- hdu 3999 The order of a Tree
- hdu 3999 The order of a Tree
- hdu 3999 The order of a Tree
- HDU 3999 The order of a Tree
- hdu 3999 The order of a Tree
- hdu 3999 The order of a Tree
- The order of a Tree HDU
- HDU The order of a Tree
- The order of a Tree HDU
- HDU-3999 The order of a Tree 树的遍历
- HDU 3999 The order of a Tree 二叉树
- 多效第16场 HDU 3999 The order of a Tree(二叉树)
- 统计代码有效行数
- 省市联动的JSON格式数据
- 面试总结-成长之路
- 总结div水平居中的方法
- MapReduce实现寻找共同好友
- hdu 3999 The order of a Tree
- 数字统计(NOIP2010)
- Ubuntu 16.04 ssh安装--个人心得
- sparkSQL架构分析
- PHP进阶(第二弹:类和对象)
- 1.quartz框架了解
- maven eclipse tomcat 启动报错 java.lang.ClassNotFoundException: org.springframework.web.filter.Character
- Error:Execution failed for task ':app:validateSigningDebug'. > Keystore file D:\Android_keystore\deb
- 在ssm框架中出现找不到资源文件错误