void porder(BTree *b)
{
BTree *St[MaxSize],*p;
int top=;
if(b!=NULL)
{
top++;
St[top]=b;
while(top>-)
{
p=St[top];
top--;
printf("%c",p->data);
if(p->rchild!=NULL)
{
top++;
St[top]=p->rchild;
}
if(p->lchild!=NULL)
{
top++;
St[top]=p->lchild;
}
}
}
} void psorder(BTree*t)
{
BTree *St[MaxSize];
BTree*p;
int flag,top=-;
do
{
while(t)
{
top++;
St[top]=t;
t=t->lchild;
}
p=NULL;
flag=;
while(top!=-&&flag)
{
t=St[top];
if(t->rchild==p)
{
printf("%c ",t->data);
top--;
p=t;
}
else
{
t=t->rchild;
flag=;
}
}
}while(top!=-)
} int level(BTree *b,ElemType x,int h)
{
int h1;
if(b==NULL)
return();
else
if(b->data==x)
return(h);
else
{
h1=level(b->lchild,x,h+);
if(h1!=)
return(h1);
else
return level(b->rchild,x,h+);
}
} void translevel(BTree *b)
{
struct node
{
BTree *vec[MaxSize];
int f,r;
}Qu;
Qu.f=;
Qu.r=;
if(b!=NULL)
printf("%c ",b->data);
Qu.vec[Qu.r]=b;
Qu.r=Qu.r+;
while(Qu.f<Qu.r)
{
b=Qu.vec[Qu.f];
Qu.f=Qu.f+;
if(b->lchild!=NULL)
{
printf("%c",b->lchild->data);
Qu.vec[Qu.r]=b->lchild;
Qu.r=Qu.r+;
}
if(b->rchild!=NULL)
{
printf("%c ",b->rchild->data);
Qu.vec[Qu.r]=b->rchild;
Qu.r=Qu.r+;
}
}
printf("\n");
}

二cha树的更多相关文章

  1. 二维树状数组 BZOJ 1452 [JSOI2009]Count

    题目链接 裸二维树状数组 #include <bits/stdc++.h> const int N = 305; struct BIT_2D { int c[105][N][N], n, ...

  2. HDU1559 最大子矩阵 (二维树状数组)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1559 最大子矩阵 Time Limit: 30000/10000 MS (Java/Others)  ...

  3. [.net 面向对象程序设计进阶] (6) Lamda表达式(二) 表达式树快速入门

    [.net 面向对象程序设计进阶] (6) Lamda表达式(二) 表达式树快速入门 本节导读: 认识表达式树(Expression Tree),学习使用Lambda创建表达式树,解析表达式树. 学习 ...

  4. POJMatrix(二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 22058   Accepted: 8219 Descripti ...

  5. poj 1195:Mobile phones(二维树状数组,矩阵求和)

    Mobile phones Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 14489   Accepted: 6735 De ...

  6. Codeforces Round #198 (Div. 1) D. Iahub and Xors 二维树状数组*

    D. Iahub and Xors   Iahub does not like background stories, so he'll tell you exactly what this prob ...

  7. POJ 2155 Matrix(二维树状数组+区间更新单点求和)

    题意:给你一个n*n的全0矩阵,每次有两个操作: C x1 y1 x2 y2:将(x1,y1)到(x2,y2)的矩阵全部值求反 Q x y:求出(x,y)位置的值 树状数组标准是求单点更新区间求和,但 ...

  8. [poj2155]Matrix(二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 25004   Accepted: 9261 Descripti ...

  9. POJ 2155 Matrix (二维树状数组)

    Matrix Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 17224   Accepted: 6460 Descripti ...

随机推荐

  1. css3 翻牌效果

    <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/h ...

  2. OD提示 "为了执行系统不支持的动作, OllyICE 在这个被调试的程序中注入了一点代码, 但是经过5秒仍未收到响应..." 解决办法

    别的OD就可以,我自己整合过的一个很顺手的OD就是不行,最后找到了解决办法: 转自:http://bbs.pediy.com/showthread.PHP?t=97629 -------------- ...

  3. JS如何获取页面可见区域高度

    window.document.body.clientHeight就可以 window.screen.availWidth 返回当前屏幕宽度(空白空间) window.screen.availHeig ...

  4. javascript中类的属性访问权限研究(1)

    本篇文章主要针对javascript的属性进行分析,由于javascript是一种基于对象的语言,本身没有类的概念,所以对于javascript的类的定义有很多名字,例于原型对象,构造函数等,它们都是 ...

  5. linux:基本命令

    1.显示日期与时间:date 显示2009/08/17形式的格式:date +%Y/%m/%d 显示17:04时间格式:date +%H/%M 2.显示日历:cal 常用的命令:cal 2009:ca ...

  6. Raphael的鼠标over move out事件

    Raphael的鼠标over move out事件 <%@ page language="java" contentType="text/html; charset ...

  7. Bootstrap入门(十三)组件7:导航条

    Bootstrap入门(十三)组件7:导航条 1.默认样式的导航条 2.嵌入表单和按钮 3.嵌入文本和非导航的链接 4.组件排列和下拉菜单 5.固定在顶部/底部 6.反色的导航条 7.路径导航 首先先 ...

  8. Bootstrap入门(十)组件4:按钮组与下拉菜单结合

    Bootstrap入门(十)组件4:按钮组与下拉菜单结合   先引入本地的CSS文件和JS文件(注:1.bootstrap是需要jQuery支持的.2.需要在<body>当中添加) < ...

  9. 蓝桥杯java试题《洗牌》

    问题描述 小弱T在闲暇的时候会和室友打扑克,输的人就要负责洗牌.虽然小弱T不怎么会洗牌,但是他却总是输. 渐渐地小弱T发现了一个规律:只要自己洗牌,自己就一定会输.所以小弱T认为自己洗牌不够均匀,就独 ...

  10. Nancy简单实战之NancyMusicStore(四):实现购物车

    前言 上一篇,我们完成了商品的详情和商品的管理,这一篇我们来完成最后的一个购物车功能. 购物车,不外乎这几个功能:添加商品到购物车,删除购物车中的商品,对购物车中的商品进行结算. MVC MusicS ...