首页 > 其他 > 详细

二叉树的中序遍历

时间:2016-03-18 21:49:51      阅读:194      评论:0      收藏:0      [点我收藏+]

二叉树的遍历方式 忘得差不多了 .......应该在记一下

 技术分享

技术分享

技术分享

歌词不是重点  重点是 知识(装一下逼)   下面附上代码  和  二叉树的 遍历 顺序 

#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
typedef struct
{
    int x, y;
}node;
node num[20];
void fun(int n)
{
    if(n == -1)
        return;
    fun(num[n].x);
    printf("%d\n", n);
    fun(num[n].y);
}

int main(){
    int chioce, i, n, m ,f, x, y;
    scanf("%d", &chioce);
    while(chioce--)
    {
        scanf("%d", &n);
        for(i = 0; i < 14; i++)
            num[i].x = num[i].y = 0;

        while(n--)
        {
            scanf("%d%d%d", &f, &x, &y);
            num[f].x = x;
            num[f].y = y;
        }
        scanf("%d", &m);
        while(m--)
        {
            scanf("%d%d", &x, &y);
        }
        fun(0);
        printf("\n");
    }
    return 0;
}

 

二叉树的中序遍历

原文:http://www.cnblogs.com/A-FM/p/5293447.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!