看看我的节目 [英] have a look at my program

查看:62
本文介绍了看看我的节目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的作业制作了这个程序plzz检查这个并更正我必须在凌晨12:00之前提交的错误











I have made this program for my assignment plzz check this and correct the errors i have to submit it latest by 12:00am





#include<stdio.h>
#include<stdlib.h>
#include<conio.h>

struct node
{
    int element;
    struct node* left;
    struct node* right;
};

typedef struct node* ptrtonode;
typedef ptrtonode searchtree;
typedef ptrtonode position;
/*
struct treenode
{
    int Element;
    treenode *Left;
    treenode *Right;
};

typedef struct treenode *PtrToNode;
typedef struct *PtrToNode searchtree;
typedef struct *PtrToNode Position;

searchtree tree(int x,searchtree T);
void preorder(searchtree T);

*/

searchtree tree(int x,searchtree T);
void preorder(searchtree T);

int main()
{
    int T=NULL;
    
    
    freopen("inp.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int  c,i=0;
    int array[100];
    
    while((scanf("%d",&c))!=EOF)
    {
        array[i++]=c;
        //printf("%d",c);
        tree(c,T);
        
    }
    
    preorder(T);
    return 0;
}





searchtree tree(int x,searchtree T)
{

    //searchtree T;
    if(T==NULL)
    {
        T=malloc(sizeof(struct node));
        T->element=x;
        T->left=NULL;
        T->right=NULL;
    }
    
    else
    if(T!=NULL)
    {
    
        if(x<t->element)
        {
            T->left=tree(x,T->left);
        }
        
    else
    if(x>T->right)
    {
        T->right=tree(x,T->right);
    }
    
    }
    
}
void preorder(searchtree T)
{

if(T!=NULL)
    {
        printf("%d",T->element);
        
        preorder(T->left);
        preorder(T->right);
    }
    
}

推荐答案

有很多问题~~~



首先检查语法问题。
Have a lot of problem~~~

check syntax problem at first.


这篇关于看看我的节目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆