Often some are printed by the layer of binary tree, the key to such problems is, when to break the problem.
This question in the cattle and the network of the explanation let me head very big, also do not understand very much. It happens that the sword refers to the offer inside there is this problem, the inside of the resolution is clearly more.
First construct a queue, set two properties a nowline is initialized to 0, which is used to save the number of elements of the currently printed line that are not yet printed.
Set another variable nextline variable to hold the total number of elements in the next row, initialized to 0.
For example,
First step: Create a new queue, set nowline=1,nextline=0,.
The second step: the head node of the content a into the queue, this time from the queue pop-up elements, the nowline minus 1, a two sub-tree content successively added to the queue, each join a queue, to nextline plus 1
The third step: detect nowline is not equal to 0, if not equal to zero, continue to eject, perform the second step after the content, if equal to 0, then let Nowline=nextline, and let nextline=0, and print a newline;
Fourth step: And so on until there is no content in the queue
Dig the pits, then write the code ...
Binary tree printing by layer, and wrapping by layer method