You are supposed to output, in decreasing order, all the elements no less than X in a binary search tree T.

Format of function:

void Print_NLT( Tree T,  int X );

where Tree is defined as the following:

typedef struct TreeNode *Tree;
struct TreeNode {
int Element;
Tree Left;
Tree Right;
};

The function is supposed to use Output(X) to print X.

Sample program of judge:

#include <stdio.h>
#include <stdlib.h> typedef struct TreeNode *Tree;
struct TreeNode {
int Element;
Tree Left;
Tree Right;
}; Tree BuildTree(); /* details omitted */
void Output( int X ); /* details omitted */ void Print_NLT( Tree T, int X ); int main()
{
Tree T;
int X; T = BuildTree();
scanf("%d", &X);
Print_NLT( T, X );
printf("End\n"); return 0;
} /* Your function will be put here */

Sample Output 1 (for the tree shown in Figure 1):

92 91 90 85 81 80 End

Figure 1

Sample Output 2 (for the tree shown in Figure 2):

End

Figure 2

 
哈哈 好巧妙,树的遍历就是好用
 
代码:
void Print_NLT( Tree T,  int X )
{
if(T == NULL)return;
Print_NLT(T -> Right,X);
if(T -> Element >= X)printf("%d ",T -> Element);
Print_NLT(T -> Left,X);
}

6-20 No Less Than X in BST(20 分)的更多相关文章

  1. 2016年11月20日 星期日 --出埃及记 Exodus 20:11

    2016年11月20日 星期日 --出埃及记 Exodus 20:11 For in six days the LORD made the heavens and the earth, the sea ...

  2. 【福利】FL Studio 20 汉化补丁包 _FL Studio 20 汉化包下载

    我这两天在网上搜索FL Studio 20汉化包,找了半天也没有找到真正的汉化包,不过好在功夫不负有心人,让我找到了一个不错的FL Studio 20汉化网站,里面提供了FL Studio 20汉化包 ...

  3. C8051逆向电阻屏:头儿拍脑袋说电阻屏IC好赚钱3块钱成本能卖20几块。,一个月不分昼夜逆向成功后头儿说电阻屏已经被市场淘汰请放弃治疗。

    参考: 书籍,<圈圈教你玩USB>  C8051F单片机快速入门:http://www.waveshare.net/Left_Column/C8051F_Application_Notes ...

  4. 【PAT甲级】1115 Counting Nodes in a BST (30分)(二叉查找树)

    题意: 输入一个正整数N(<=1000),接着输入N个整数([-1000,1000]),依次插入一棵初始为空的二叉排序树.输出最底层和最底层上一层的结点个数之和,例如x+y=x+y. AAAAA ...

  5. 得到一个a(10)到b(20)的随机数。包括10和20

  6. PAT_A1115#Counting Nodes in a BST

    Source: PAT A1115 Counting Nodes in a BST (30 分) Description: A Binary Search Tree (BST) is recursiv ...

  7. [MySQL Reference Manual] 20 分区

    20 分区 20 分区 20.1 MySQL的分区概述 20.2 分区类型 20.2.1 RANGE分区 20.2.2 LIST分区 20.2.3 COLUMNS分区 20.2.3.1 RANGE C ...

  8. [转]MIDI常识20条

    原文链接:http://www.midifan.com/modulearticle-detailview-488.htm Keyboard杂志老资格编辑Jim Aikin在纪念MIDI诞生20的时候发 ...

  9. ITK 3.20.1 VS2010 Configuration 配置

    Download ITK 3.20.1 Download VS2010 Download CMake 3.2.0 I assume you've already installed VS2010 an ...

  10. 《javascript高级程序设计》 第20章 JSON

    20.1 语法 20.1.1 简单值 20.1.2 对象 20.1.3 数组 20.2 解析与序列化 20.2.1 JSON 对象 20.2.2 序列化选项 20.2.3 解析选项 JSON 对象有两 ...

随机推荐

  1. html canvas 圆弧

    contxt.arc(x, y , r, 0 , 弧 1.5*Math.PI PI要注意大小写 , 顺时针=false 逆时针 true) 例如  context.arc(300, 300, 200, ...

  2. DLL文件是怎么产生的,DLL文件是什么,DLL文件有什么用

    ①DLL文件是怎么产生的 许多应用程序被分割成一些相对独立的动态链接库,放置于系统中,就产生了DLL文件. ②DLL文件是什么 DLL(Dynamic Link Library)文件为动态链接库文件, ...

  3. update t_conference set c_address = replace(c_address,'中华人民共和国','');

    update t_conference set c_address = replace(c_address,'中华人民共和国','中国');      //把c_address字段中的‘中华人民共和国 ...

  4. IMX6Q GPIO定义

    ret = gpio_request_array(mx6q_sabresd_flexcan_gpios,                        ARRAY_SIZE(mx6q_sabresd_ ...

  5. impress.js初体验——前端装X利器

    impress.js 是国外一位开发者受 Prezi 启发,采用 CSS3 与 JavaScript 语言完成的一个可供开发者使用的表现层框架(演示工具).其功能包括画布的无限旋转与缩放,任意角度放置 ...

  6. Tomcat灵活配置多项目,多端口,多域名,多虚拟目录

    Tomcat的配置都在Tomcat的安装目录的conf文件夹下的server.xml文件 最初内容:(去掉所有注释) <?xml version="1.0" encoding ...

  7. G_M_网络流A_网络吞吐量

    调了两天的代码,到最后绝望地把I64d改成lld就过了,我真的是醉了. 网络吞吐量 题面:给出一张(n个点,m条边)带权(点权边权均有)无向图,点权为每个点每秒可以接受发送的最大值,边权为花费,保证数 ...

  8. [BZOJ1257][CQOI2007]余数之和

    题目大意 给你 \(n, k\),计算 $ \sum_{i=1}^n k \bmod i$ 解析 注意到 $ k\bmod i=k-[k/i] \times i$ 则上式等于 $ n \times k ...

  9. vue项目打包部署到nginx 服务器上

    假如要实现的效果如下 http://ip/vue    =>是进入首页访问的路径是  usr/local/nginx/html/vue http://ip/website     =>是进 ...

  10. apache允许列目录

    vi /etc/httpd/conf.d/welcom.conf <LocationMatch "^/+$">    #Options -Indexes vi /etc ...