|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 Romeo 于 2018-6-23 23:33 编辑
- #include <stdio.h>
- #include <stdlib.h>
- typedef char ElementType;
- typedef struct BiTNode{
- ElementType data;
- struct BiTNode *lChild, *rChild;
- }BiTNode, *BiTree;
- //创建一棵二叉树
- void CreateBiTree(BiTree T){
- char c;
- scanf("%c", &c);
- if (' ' == c) {
- T = NULL;
- } else {
- T = (BiTNode *) malloc(sizeof(BiTNode));
- T->data = c;
- CreateBiTree(&(T)->lChild);
- CreateBiTree(&(T)->rChild);
- }
- }
- int main() {
- BiTree Tree;
- CreateBiTree(Tree);
- return 0;
- }
复制代码
用CreateBiTree(BiTree T)创建二叉树后,Tree仍为空。 |
|