Exemple #1
0
void printTreeInorder(pnode root) { 
    if (root == NULL) return;
    
    printTreeInorder(root->left);
    printf("%d\n", root->data);
    printTreeInorder(root->right);
}
/****************************************************************
 INORDER
 Print a BST in Left-Root-Right sequence.
 */
void printTreeInorder( int *maxlength, NODE *root, FILE **fpOutput )
{
    QUEUE *front = NULL;
    if( root ){
        printTreeInorder( maxlength, root->left, fpOutput);
        fprintf( *fpOutput, "%-3d ",  root->count );
        fprintf( *fpOutput, "%-*s ",  *maxlength, root->word );
        int n=0;
        while (root->front != NULL)
        {
            front = dequeue(&root->front, &root->rear);
            if (front)
            {
                fprintf(*fpOutput, "%2d.%02d  ",front->page, front->line);
                free(front);
                n++;
                if (n%8==0)
                    fprintf(*fpOutput, "\n%-*s",4+*maxlength+1, "");
            }
        }
        fprintf(*fpOutput, "\n");
        printTreeInorder( maxlength, root->right, fpOutput);
    }
    return;
}