수식 트리.png


오류.png


#include <stdio.h>

#include <stdlib.h>

#include <memory.h>


void preorder(char atree[], int i)

{

if(atree[i]!= '\0'|| i < 16){

printf("%c",atree[i]);

preorder(atree,i*2);

preorder(atree, i*2+1);

}

}


void inorder(char atree[],int i)

{

if(atree[i]!='\0'|| i < 16){

inorder(atree,i*2);

printf("%c",atree[i]);

inorder(atree,i*2+1);

}

}


void postorder(char atree[], int i)

{

if(atree[i]!= '\0'|| i < 16){

postorder(atree,i*2);

postorder(atree,i*2+1);

printf("%c",atree[i]);

}

}


void main()

{

char ArrayTree[16]={0,'A','3','*','2','B','4','-','1','C','6','/','5','D','7',0};


printf("\n preorder : ");

preorder(ArrayTree, 1);


printf ("\n inorder :");

inorder(ArrayTree, 1);


printf("\n postorder: ");

postorder(ArrayTree, 1);


getchar();

}


바꿔줘도 저래 뜬다 ㅠ