输出以二叉树表示的算术表达式(严6.51)--------西工大noj
2024-10-20 18:19:44
题解
这道题目说的很诡异,其实没有什么把括号补上。。。。仅仅是先序读入,然后中序输出就行了
代码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct TreeNode
{
char data;
struct TreeNode *LChild, *RChild;
}TreeNode;
char *c;
void Create(TreeNode **T)
{
if(*c=='#')
{
(*T) = NULL;
c++;
return ;
}
(*T) = (TreeNode*)malloc(sizeof(TreeNode));
(*T)->data = *c;
c++;
Create(&(*T)->LChild);
Create(&(*T)->RChild);
}
void Print(TreeNode*T)
{
if(!T)
return;
Print(T->LChild);
printf("%c",T->data);
Print(T->RChild);
}
int main()
{
static char buf[10000];
scanf("%s",buf);
c = buf;
TreeNode *T;
Create(&T);
Print(T);
return 0;
}
/*
*+a(###b#)##c##
*/
最新文章
- 使用 Vue 2.0 实现服务端渲染的 HackerNews
- 结构体内嵌函数指针实现C语言面向对象
- flash全屏输入模式
- GridControl 继承写法修改自己的GridControl
- C# Socket通信 小案例
- Spring mvc中@RequestMapping 6个基本用法整理
- 3522: [Poi2014]Hotel( 树形dp )
- C# Web.config 配置handlers 和 httpHandlers
- Storm学习笔记 - 消息容错机制
- js基础语句
- linux:644、755、777权限详解
- 51nod--1298 (计算几何基础)
- Python 文件操作三
- Spring MVC 和 Struts2 的比较
- ActiveMQ 集群负载平衡
- opencv2.4.10与VS2013的环境配置
- Part15 – 前端之jQuery
- Unity3d实现幸运转盘
- 【POJ】1185 炮兵阵地(状压dp)
- win8平板APP开发的教程文章