Language: C

#include<stdio.h>
typedef struct{
  int number;
  int son[2];//???
  int reach;
  int parent;
  int sibling;
  int degree;
  int height;
}node;
 
node B[10000];
int n;
int a;
int flag=0;
 
void preorder(int num){
  //  if(num!=a)printf(" ");
  printf(" %d",B[num].number);
  if(B[num].son[0]!=-1)preorder(B[num].son[0]);
  if(B[num].son[1]!=-1)preorder(B[num].son[1]);
 
}//OK
 
void inorder(int num){
  /* {
      printf(" %d",B[num].number);
      return;
      }*/
    if(B[num].son[0]!=-1)inorder(B[num].son[0]);
      printf(" %d",B[num].number);
  if(B[num].son[1]!=-1)inorder(B[num].son[1]);
 
  }
 
void postorder(int num){
   
  /* if(B[num].son[0]==-1){
    printf(" %d",B[num].number);
    return;
    }*/
if(B[num].son[0]!=-1)postorder(B[num].son[0]);
  /*  if(B[num].son[1]==-1){
    printf(" %d",B[num].number);
    return;
    }*/
  if(B[num].son[1]!=-1)postorder(B[num].son[1]);
  printf(" %d",B[num].number);
}//OK
 
int parent(int num){//parent input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    for(j=0;j<2;j++){
      if(num==B[i].son[j]){
    r=i;
    return r;
      }
    }
  }
  return r;
}
 
int reach(int num){//reach input
  int i,r=0;
  for(i=0;i<n;i++){
    if(B[num].parent==-1)return r;
    else {
      num=B[num].parent;
      r++;
    }
  }
}
 
int sibling(int num){//sibling input
  int i,j,r=-1;
  for(i=0;i<n;i++){
    if(i!=num){
      if(B[num].parent==B[i].parent){
    r=i;
    return r;
      }
    }
  }
  return r;
}
 
int height(int num,int r,int parent){//height input
  //  printf("r = %d num = %d\n",r,num);
  if(parent==B[num].parent)r=0;
  if(B[num].son[0]==-1)return r;
  r++;
  r=height(B[num].son[0],r,parent);
  r=height(B[num].son[1],r,parent);
  
  return r;
}
 
int main(){
  int i,j,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    B[i].parent=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&a);
    B[a].number=a;
    for(j=0;j<2;j++){
      scanf("%d",&k);
      B[a].son[j]=k;
      B[k].parent=a;
      if(k==-1)B[a].degree=0;
      else B[a].degree=2;
    }
  }
 
  /*  for(i=0;i<n;i++){
    B[i].parent=parent(i);
  }
  */
   
  for(i=0;i<n;i++){
    B[i].reach=reach(i);
  }
   
  for(i=0;i<n;i++){
    B[i].sibling=sibling(i);
  }
   
  /*  for(i=0;i<n;i++){
    B[i].height=height(i,0,B[i].parent);
  }
  */
  for(i=0;i<n;i++){
    if(B[i].parent==-1){
      a=i;
      break;
    }
  }
  printf("Preorder\n");
   preorder(a);
  printf("\nInorder\n");
   inorder(a);
  printf("\nPostorder\n");
   postorder(a);
  printf("\n");
 
 
  return 0;
}

Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 8/8	C	CPU: 00.00 sec	Memory: 0 KB	Length: 2468 B	2012-05-30 15:03	2012-05-30 15:03
Results for testcases
Case #	Verdict	CPU Time	Memory	In	Out	Case Name
Case #1:	: Accepted	-	-	38 B	60 B	1.in
Case #2:	: Accepted	-	-	10 B	36 B	2.in
Case #3:	: Accepted	-	-	31 B	54 B	3.in
Case #4:	: Accepted	-	-	52 B	72 B	4.in
Case #5:	: Accepted	-	-	66 B	84 B	5.in
Case #6:	: Accepted	-	-	52 B	72 B	6.in
Case #7:	: Accepted	-	-	164 B	180 B	7.in
Case #8:	: Accepted	-	-	199 B	216 B	8.in

< prev |	1	/	8	| next >	 		 : Accepted        -        -
 
Judge Input #1 ( in1.txt | 38 B)		Judge Output #1 ( out1.txt | 60 B)
5
3 4 0
4 -1 -1
1 -1 -1
2 -1 -1
0 1 2
Preorder
 3 4 0 1 2
Inorder
 4 3 1 0 2
Postorder
 4 1 2 0 3
Comments
 
 Under Construction.
 
Categories
 
 
Free Tags
 
 

Compiler output:
main.c:152:1: error: unknown type name 'Compile'
  152 | Compile Error Logs:
      | ^~~~~~~
main.c:152:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Logs'
  152 | Compile Error Logs:
      |               ^~~~
main.c:158:6: error: stray '#' in program
  158 | Case #  Verdict CPU Time        Memory  In      Out     Case Name
      |      ^
main.c:159:6: error: stray '#' in program
  159 | Case #1:        : Accepted      -       -       38 B    60 B    1.in
      |      ^
main.c:159:65: error: invalid suffix "in" on floating constant
  159 | Case #1:        : Accepted      -       -       38 B    60 B    1.in
      |                                                                 ^~~~
main.c:160:6: error: stray '#' in program
  160 | Case #2:        : Accepted      -       -       10 B    36 B    2.in
      |      ^
main.c:160:65: error: invalid suffix "in" on floating constant
  160 | Case #2:        : Accepted      -       -       10 B    36 B    2.in
      |                                                                 ^~~~
main.c:161:6: error: stray '#' in program
  161 | Case #3:        : Accepted      -       -       31 B    54 B    3.in
      |      ^
main.c:161:65: error: invalid suffix "in" on floating constant
  161 | Case #3:        : Accepted      -       -       31 B    54 B    3.in
      |                                                                 ^~~~
main.c:162:6: error: stray '#' in program
  162 | Case #4:        : Accepted      -       -       52 B    72 B    4.in
      |      ^
main.c:162:65: error: invalid suffix "in" on floating constant
  162 | Case #4:        : Accepted      -       -       52 B    72 B    4.in
      |                                                                 ^~~~
main.c:163:6: error: stray '#' in program
  163 | Case #5:        : Accepted      -       -       66 B    84 B    5.in
      |      ^
main.c:163:65: error: invalid suffix "in" on floating constant
  163 | Case #5:        : Accepted      -       -       66 B    84 B    5.in
      |                                                                 ^~~~
main.c:164:6: error: stray '#' in program
  164 | Case #6:        : Accepted      -       -       52 B    72 B    6.in
      |      ^
main.c:164:65: error: invalid suffix "in" on floating constant
  164 | Case #6:        : Accepted      -       -       52 B    72 B    6.in
      |                                                                 ^~~~
main.c:165:6: error: stray '#' in program
  165 | Case #7:        : Accepted      -       -       164 B   180 B   7.in
      |      ^
main.c:165:65: error: invalid suffix "in" on floating constant
  165 | Case #7:        : Accepted      -       -       164 B   180 B   7.in
      |                                                                 ^~~~
main.c:166:6: error: stray '#' in program
  166 | Case #8:        : Accepted      -       -       199 B   216 B   8.in
      |      ^
main.c:166:65: error: invalid suffix "in" on floating constant
  166 | Case #8:        : Accepted      -       -       199 B   216 B   8.in
      |                                                                 ^~~~
main.c:170:13: error: stray '#' in program
  170 | Judge Input #1 ( in1.txt | 38 B)                Judge Output #1 ( out1.txt | 60 B)
      |             ^
main.c:170:62: error: stray '#' in program
  170 | Judge Input #1 ( in1.txt | 38 B)                Judge Output #1 ( out1.txt | 60 B)
      |                                                              ^