#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. PAT-1003 Emergency (25 分) 最短路最大点权+求相同cost最短路的数量

    As an emergency rescue team leader of a city, you are given a special map of your country. The map s ...

  2. Java锁的升级策略 偏向锁 轻量级锁 重量级锁

    这三种锁是指锁的状态,并且是专门针对Synchronized关键字.JDK 1.6 为了减少"重量级锁"的性能消耗,引入了"偏向锁"和"轻量级锁&qu ...

  3. java小工具:通过URL连接爬取资源(图片)

    java语言编写一个简单爬取网站图片工具,实现简单: 通过 java.net.HttpURLConnection 获取一个URL连接 HttpURLConnection 连接成功返回一个java.io ...

  4. php实现命令行里输出带颜色文字

    今天执行composer的时候看到命令窗口出现的提示里面有的关键性部分带有颜色,于是很好奇研究了一下,在这里记录下来 其实在命令行输出带颜色字体主要是使用的 ANSI 转义字符实现的,我们先看个例子: ...

  5. printPreviewControl1怎么刷新文档

    printPreviewControl1.InvalidatePreview(); 调用printPreviewControl1控件的  InvalidatePreview() 这个方法即可.

  6. vue拦截

    ```javascript import Vue from 'vue' import App from './App.vue' import router from './router' import ...

  7. html5+css3 background-clip 技巧

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. shell code

  9. Ubuntu18.0 解决python虚拟环境中不同用户下或者python多版本环境中指定虚拟环境的使用问题

    一. 不同用户下配置virtualenvwrapper的问题 问题描述: 安装virtualnev和virtualnevwrapper之后,在.bashrc进行virtualenvwrapper的相关 ...

  10. PropTypes没有定义的问题

    今天做项目遇到了一个坑 import React, { Component,PropTypes} from 'react'; console.log(PropTypes); //undefined 用 ...