  1 #include<stdio.h>
  2 #include<stdlib.h>
  3 
  4 int main(void){
  5         int size;
  6         int *A;
  7         int i;
  8 
  9         scanf("%d",&size);
 10 
 11         A=(int*)malloc(sizeof(int)*(size+1));
 12 
 13         for(i=1;i<=size;i++) scanf("%d",&A[i]);
 14 
 15         for(i=1;i<=size;i++){
 16                 printf("node %d: ",i);
 17                 printf("key = %d, ",A[i]);
 18                 if(i/2 > 0) printf("parent key = %d, ",A[i/2]);
 19                 if(2*i <= size) printf("left key = %d, ",A[2*i]);
 20                 if(2*i+1 <= size) printf("right key = %d, ",A[2*i+1]);
 21                 printf("\n");
 22         }
 23 
 24         return 0;
 25 }
~                                                                                             
~                                                                                             
~                                                                                             
~                                                                                             
~                                                                                             
~                         