#include <bits/stdc++.h>
using namespace std;
struct node
{
char data;
struct node *lc, *rc;
};
char a[100];
int num = 0;
struct node *creat()
{
struct node *root;
if(a[num++] == ',')
{
root = NULL;
}
else {
root = new node;
root -> data = a[num - 1];
root -> lc = creat();
root -> rc = creat();
}
return root;
};
void fin(struct node *root)
{
struct node *q[100];
int in = 0, out = 0;
q[in ++] = root;
while(out < in){
if(q[out])
{
if(q[out] -> lc == NULL && q[out] -> rc == NULL) printf("%c",q[out]->data);
q[in++] = q[out]->lc;
q[in++] = q[out] -> rc;
}
out ++;
}
}
int main()
{
while(~scanf("%s", a))
{
struct node *root;
num =0;
root = creat();
fin(root);
printf("\n");
}
return 0;
}

数据结构实验之二叉树七:叶子问题(SDUT 3346)的更多相关文章

  1. SDUT 3346 数据结构实验之二叉树七:叶子问题

    数据结构实验之二叉树七:叶子问题 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 已知一个按 ...

  2. SDUT OJ 数据结构实验之二叉树七:叶子问题

    数据结构实验之二叉树七:叶子问题 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descri ...

  3. SDUT-3346_数据结构实验之二叉树七:叶子问题

    数据结构实验之二叉树七:叶子问题 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 已知一个按先序输入的字符序列,如abd ...

  4. SDUT 3345 数据结构实验之二叉树六:哈夫曼编码

    数据结构实验之二叉树六:哈夫曼编码 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 字符的编 ...

  5. SDUT OJ 数据结构实验之二叉树三:统计叶子数

    数据结构实验之二叉树三:统计叶子数 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Descr ...

  6. SDUT 3342 数据结构实验之二叉树三:统计叶子数

    数据结构实验之二叉树三:统计叶子数 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 已知二叉 ...

  7. SDUT 3340 数据结构实验之二叉树一:树的同构

    数据结构实验之二叉树一:树的同构 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 给定两棵树 ...

  8. SDUT 3344 数据结构实验之二叉树五:层序遍历

    数据结构实验之二叉树五:层序遍历 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 已知一个按 ...

  9. SDUT OJ 数据结构实验之二叉树八:(中序后序)求二叉树的深度

    数据结构实验之二叉树八:(中序后序)求二叉树的深度 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Probl ...

随机推荐

  1. javascript 垃圾回收机制和内存管理

    前言:这是笔者学习之后自己的理解与整理.如果有错误或者疑问的地方,请大家指正,我会持续更新! 垃圾回收机制的原理是找到不再被使用的变量,然后释放其占用的内存,但这个过程不是时时的,因为其开销比较大,所 ...

  2. hdu 1203 转换的01包问题。。。。

    俗话说的话 正难则反.,.  这个基本的思想都用不好的话 回家种田去吧. #include<cstdio> #include<string.h> #include<ios ...

  3. koa-router学习笔记

    koa-router 是koa框架的一个路由处理级别的中间件. 目录结构 ├── app.js ├── middleware │ ├── m1.js │ └── m2.js ├── package-l ...

  4. Java代理模式示例程序

    Java代理模式示例程序 当然不是我想出来的,是我看的一个网上教程里的. 模拟的是一个对电脑公司的代理 真实类的接口: public interface SaleComputer { public S ...

  5. 补充:Python安装

    需要安装Python2.7.Numpy和Matplotlib.由于Python不支持向下兼容,因此在Python3.×下你一定能正常运行Python2.×的代码.上述模块最简单的安装方法就是用软件包安 ...

  6. 【推荐】 Neutralizer 安卓上特殊的均衡器

    首先 直切正题 这个均衡器特殊就特殊在   会产生  特定频率的声音   根据声音来调整  自己喜欢的声音 下载地址: https://d-02.apkplz.org/dl.php?s=czlDeEt ...

  7. 页面中的div居中

    div的居中 一.页面的水平居中 #article{ position: relative; margin: 0 auto; width: 80%; background-color: aquamar ...

  8. 嵌套的页面——自适应高度与跨越操作DOM

    <div id="myIframeId"> <iframe ref="myIframe" name="odpIframeName&q ...

  9. redis slot 槽点

    Redis 集群中内置了 16384 个哈希槽,当需要在 Redis 集群中放置一个 key-value 时,redis 先对 key 使用 crc16 算法算出一个结果,然后把结果对 16384 求 ...

  10. 一组简单好看的css3渐变按钮

    主要代码如下: body { background:#fff } /* Mixins */ /* bg shortcodes */ .bg-gradient1 span,.bg-gradient1:b ...