| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 735 人关注过本帖
标题:大家看看噢,这个是怎么的错误,老是运行不对!!
只看楼主 加入收藏
tanghf1014
Rank: 2
等 级:论坛游民
帖 子:37
专家分:37
注 册:2010-10-15
结帖率:77.78%
收藏
已结贴  问题点数:5 回复次数:3 
大家看看噢,这个是怎么的错误,老是运行不对!!
#incldue<stdafx.h>
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef char DataType;

struct TreeNode{
    DataType data;
    struct TreeNode *lchild,*rchild;
};
typedef TreeNoDE *BinTree;
BinTree CreateBinTree(){
    char ch;
    printf("shuruzhifu\n");
    scanf("%c",&ch);
    TreeNode* pNode;
    if(ch=='0'){
        pNode=Null;
    }
    else{
        pNode=(TreeNode*)malloc(sizeof(TreeNode));
        if(pNode==NULL){
            printf("shengqingkongjianshibai");
            exit(0);
        }
        pNode->data=ch;
        pNode->lchild=CreateBinTree();
        pNode->rchild=CreateBinTree();
    }
    return pNode;
}

void PerOrder(BinTree pRoot){/*前序*/
    if(pRoot){
        pirntf("%c\n",pRoot->data);
        PerOrder(pRoot->lchild);
        PreOrder(pRoot->rchild)
    }
}
void InOrder(BinTree pRoot){/*中序*/
    if(pRoot){
        InOrder(pRoot->lchild);
        printf("%c\n",pRoot->data);
        InOrder(pRoot->rchild);
    }
}
void PostOrder(BinTree pRoot){/*后序*/
    if(pRoot){
        PostOrder(pRoot->lchild);
        PostOrder(pRoot->rchild);
        printf("%c\n",pRoot->data);
    }
}
void StackPreOrder(BinTree pRoot){
    TreeNode* stack[200];
    int top=-1;
    BinTree p=pRoot;
    stack[++top]=p;
    while(p!=NULL || top!=-1){
        if(p){
            printf("%c",p->data);
            stack[++top]=p->lchild;
        }
        else{
            p=stack[top--];
            p=p->rchild;
        }
    }
}
int main(int argc,char* argv[])
{
    BinTree pRoot;
    CreateBinTree(&pRoot);
    printf("前序遍历:");
    PreOrder(pRoot);
    printf("\n");
    printf("中序遍历:");
    InOrder(pRoot);
    printf("\n");
    printf("后序遍历:");
    PostOrder(pRoot);
    printf("\n");
    printf("\n");
    return 0;
}


//fatal error C1021: invalid preprocessor command 'incldue'
执行 cl.exe 时出错.
搜索更多相关主题的帖子: 运行 
2010-11-10 20:49
sambean
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2010-11-11
收藏
得分:0 
invalid  非法的
incldue
是 include 不是 incldue
2010-11-11 19:13
m21wo
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:4
帖 子:440
专家分:1905
注 册:2010-9-23
收藏
得分:5 
程序代码:
#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef char DataType;

struct TreeNode{
    DataType data;
    struct TreeNode *lchild,*rchild;
};// 类型说明
typedef TreeNode* BinTree;
BinTree CreateBinTree(){
    char ch;
    printf("shuruzhifu\n");
    scanf("%c",&ch);
    TreeNode* pNode;
    if(ch=='0'){
        pNode=NULL;  //  马虎
    }
    else{
        pNode=(TreeNode*)malloc(sizeof(TreeNode));
        if(pNode==NULL){
            printf("shengqingkongjianshibai");
            exit(0);
        }
        pNode->data=ch;
        pNode->lchild=CreateBinTree();
        pNode->rchild=CreateBinTree();
    }
    return pNode;
}

void PreOrder(BinTree pRoot){/*前序*/
    if(pRoot){
        printf("%c\n",pRoot->data);  //马虎
        PreOrder(pRoot->lchild);
        PreOrder(pRoot->rchild);  // 马虎
    }
}
void InOrder(BinTree pRoot){/*中序*/
    if(pRoot){
        InOrder(pRoot->lchild);
        printf("%c\n",pRoot->data);
        InOrder(pRoot->rchild);
    }
}
void PostOrder(BinTree pRoot){/*后序*/
    if(pRoot){
        PostOrder(pRoot->lchild);
        PostOrder(pRoot->rchild);
        printf("%c\n",pRoot->data);
    }
}
void StackPreOrder(BinTree pRoot){
    TreeNode* stack[200];
    int top=-1;
    BinTree p=pRoot;
    stack[++top]=p;
    while(p!=NULL || top!=-1){
        if(p){
            printf("%c",p->data);
            stack[++top]=p->lchild;
        }
        else{
            p=stack[top--];
            p=p->rchild;
        }
    }
}
int main(int argc,char* argv[])
{
    BinTree pRoot;
    pRoot=CreateBinTree(); // 这么写
    printf("前序遍历:");
    PreOrder(pRoot);
    printf("\n");
    printf("中序遍历:");
    InOrder(pRoot);
    printf("\n");
    printf("后序遍历:");
    PostOrder(pRoot);
    printf("\n");
    printf("\n");
    return 0;
}



If You Want Something, Go Get It, Period.
2010-11-11 19:18
tanghf1014
Rank: 2
等 级:论坛游民
帖 子:37
专家分:37
注 册:2010-10-15
收藏
得分:0 
看来是大马虎了...
2010-11-11 22:53
快速回复:大家看看噢,这个是怎么的错误,老是运行不对!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018745 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved