Printing a tree P19127


Statement
 

pdf   zip

thehtml

Write a program that reads a binary tree of words, and that prints it following the format of the instance.

Input

Input consists of the description of a tree as is explained at the exercise . You can suppose that the given words have less than ten letters.

Output

Your program must print the tree following the format of the instance. Notice that each level of the tree is printed using ten characters.

Public test cases
  • Input

    10
    va tenir sis -1 polls -1 -1 xics -1 -1 pics
    pellarics -1 -1 camatorts i -1 becarics -1 -1 -1
    

    Output

                         camatorts
                                              becarics
                                           i
                    pics
                         pellarics
            va
                              xics
                   tenir
                                       polls
                               sis
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++