hdu 3999 The order of a Tree
来源:互联网 发布:去哪儿软件下载 编辑:程序博客网 时间:2024/05/07 13:13
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>#include <vector>#include <queue>#include <set>#include <map>#include <string>#include <math.h>#include <stdlib.h>#include <time.h>using namespace std;typedef struct node *tree;typedef struct node{ tree left; tree right; int data;};bool f;tree in(int t,tree p){ if(!p) { p=(tree)malloc(sizeof(struct node)); p->data=t; p->left=p->right=NULL; } else { if(t<p->data) { p->left=in(t,p->left); } else if(t>p->data) { p->right=in(t,p->right); } } return p;}void preorder(tree p)//先序遍历{ if(p) { if(f) printf(" "); else f++; printf("%d",p->data); preorder(p->left); preorder(p->right); }}int main(){ int n,i,t; while(~scanf("%d",&n)) { tree root=NULL; for(i=0;i<n;i++) { scanf("%d",&t); root=in(t,root); } f=0; preorder(root); printf("\n"); }}
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(二叉树)
- poj2993
- [LeetCode]Combination Sum
- 程序设计性能优化整理(一)
- JAVA帮助文档全系列 JDK1.5 JDK1.6 JDK1.7 官方中英完整版下载
- Activity的screenOrientation属性
- hdu 3999 The order of a Tree
- Android 编程下短信监听在小米手机中失效的解决办法
- U函数,I函数和模板后缀名
- 二叉树的基本操作--1
- poj2996
- 安卓小伙征战IOS UITableView
- 蓝桥杯:历届试题 剪格子【JAVA算法实现】
- 《python核心编程第二版》第二章练习答案解析
- poj3006