Write the integers of an array vertically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • da7473
    New Member
    • Feb 2013
    • 1

    Write the integers of an array vertically

    I know this is probably very simple but I really can't seem to understand how to write the integers vertically. For instance, there is an array that has 4 integers which are 9, 21, 63, and 501, the outcome would be the following

    Code:
         9  2  5  6
            1  0  3
               1
    This is a small step of my program and probably the easiest but I can't understand how to do it :( Can someone please help me or guide me so I can finish my program
    Last edited by Rabbit; Feb 20 '13, 02:46 AM. Reason: Please use code tags when posting formatted data to preserve white space.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    The basic algorithm would look like this:

    1) Find longest element in the array.
    2) Loop from 1 to length of longest element.
    3) Nest a loop to loop through each element of the array.
    4) Append the digit at position in that element of the array if it exists, otherwise append a space.
    5) End the inner loop
    6) Append a new line.
    7) End outer loop.
    8) Output results.

    Comment

    Working...