Problem with formatting output c++ -


I am working on a binary search tree .. I'm having trouble aligning the nodes left on the output. I'm printing array order, pre-order, indoor, post order ... array order format has left the alliance as i want it .. im basically the same code (set and left; with preo order and rest However, this is not left aligned ..

I have tried everything. Any move?

The correct output ..

  Database of Great Computer Scientists>> Array Order: Name of Address - Index ---- ----- ----- Rals Ton, Anthony 0 Liang, Lee 1 von Neumann, John 2 Jones, Doug 3 Trigoboff, Michael 5 Goble, Colin Leaf 7 Nut, Donald 8 Turing, Alan's Leaf 12, Alan's Leaf 17 (Item Printed) (9) & Gt; & gt; Predender: Name of the Leaf? Index --------- ----- Ralston, Anthony Liang, Li 1 Jones, Dog 3 Goble, Colin Leaf 7 Nut, Donald 8 , Alan's Leaf 17 von Neumann, John 2 Tribofof, Michael 5 Turing, Alan's Leaf 12 (item printed) (9)>> Inorder: The name of the name Index ------------- Goble, Colin Leaf 7 Jones, Doug 3 KA, Alan Leaf 17 Nith, Donald 8 Liang, Lee 1 Ruston, Anthony Trigofoff, Michael 5 Turing, Alan Leaf 12 von Neumann, John 2 (Item printed) (9) & gt; & Gt; & Gt; Poster: name address? Index ------------- Goble, Colin Leaf 7 KA, Allan Leaf 17 Nith, Donald 8 Jones, Doug Liang 3, Li 1 Turing, Allan Leaf 12 Tribobof, Michael 5 von Neumann, John 2 Ralston, Anthony 0 (item printed) (9) & gt; & Gt; & Gt; Tribobof, Michael Tibboff, Michael & gt; & Gt; & Gt; Retrieve KEE, Danny is not found  

Here is the code for the indoor rest functions are almost identical to the set up of the output.

  BST :: displayInOrder (ostream and out, int parent) const {if (parent and lt; = maxsize) {this- & gt; Display order (out, 2 * parent + 1); If (! Item [parent]. Liberation) {Out & lt; & Lt; Left & lt; & Lt; Setup (27) & lt; & Lt; Items [original] .instanceData; Outside & lt; & Lt; True & lt; & Lt; Setw (10); If (! Item [parent] .isLeaf) {Out & lt; & Lt; Left & lt; & Lt; Setup (11) & lt; & Lt; "Leaf"; } Outside & lt; & Lt; Setup (12) & lt; & Lt; mother-father; Outside & lt; & Lt; Endl; } This- & gt; Display order (out, 2 * parent + 2); } If (! Parents) {item printed (out, size); }}  

And here is the array command code that has left the rows.

  Zero BST :: displayArrayOrder (ostream and out) const {out & Lt; & Lt; "& Gt; & gt; Array Order:" & lt; & Lt; Endl; DisplayHeaders (outside); (Int (index!); Index and lieutenant + max; max + 1; index ++) (if (item! [Index] .empty) {outside   size) {item [index] .isLeaf = False; out & lt; left & lt; set (10) & lt; "leaf";} if (objects [2 * index + 1]. Fair & amp; item [2 * Index + 2] .shirt and index; size) {item [index] .isLeaf = false; out & lt;  

make a favor to yourself Write a function to display a record, and use it anywhere to show that kind of record. Since you already have a code that works in one place, just Use your code inside your code body print_record () (or whatever you decide to call it).

One thing should be learned as soon as possible: Repeating the same basic code three or four times is actually bad thing, and you should avoid it.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -