Formatting Output

This is a discussion on Formatting Output within the C++ Programming forums, part of the General Programming Boards category; What can I do to line up the following: Code: Num:1: move disk 1 from 1 to 3. Num:2: move ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    31

    Formatting Output

    What can I do to line up the following:
    Code:
    Num:1: move disk 1 from 1 to 3.
    Num:2: move disk 2 from 1 to 2.
    Num:3: move disk 1 from 3 to 2.
    Num:4: move disk 3 from 1 to 3.
    Num:5: move disk 1 from 2 to 1.
    Num:6: move disk 2 from 2 to 3.
    Num:7: move disk 1 from 1 to 3.
    Num:8: move disk 4 from 1 to 2.
    Num:9: move disk 1 from 3 to 2.
    Num:10: move disk 2 from 3 to 1.
    Num:11: move disk 1 from 2 to 1.
    Num:12: move disk 3 from 3 to 2.
    Num:13: move disk 1 from 1 to 3.
    Num:14: move disk 2 from 1 to 2.
    Num:15: move disk 1 from 3 to 2.
    
    so that it becomes
    
    Num:1:  move disk 1 from 1 to 3.
    Num:2:  move disk 2 from 1 to 2.
    Num:3:  move disk 1 from 3 to 2.
    Num:4:  move disk 3 from 1 to 3.
    Num:5:  move disk 1 from 2 to 1.
    Num:6:  move disk 2 from 2 to 3.
    Num:7:  move disk 1 from 1 to 3.
    Num:8:  move disk 4 from 1 to 2.
    Num:9:  move disk 1 from 3 to 2.
    Num:10: move disk 2 from 3 to 1.
    Num:11: move disk 1 from 2 to 1.
    Num:12: move disk 3 from 3 to 2.
    Num:13: move disk 1 from 1 to 3.
    Num:14: move disk 2 from 1 to 2.
    Num:15: move disk 1 from 3 to 2.
    Press any key to continue
    Last edited by Aakash Datt; 05-16-2003 at 08:10 PM.

  2. #2
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    they look the same...

    try putting them in [ code ] and [ / code ] tags so that the spacing you entered is intact

    try outputting \t (tab) characters... not sure what you want

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    This isn't exactly what you want, but it's another idea to try:

    cout << "Num:" << setw(2) << num << ": move disk " << disk << " from " << from << " to " << to << endl;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Switch statement and returning the correct output
    By slowcoder in forum C Programming
    Replies: 6
    Last Post: 09-28-2006, 05:00 PM
  2. Formatting output to screen from a file
    By clearrtc in forum C Programming
    Replies: 2
    Last Post: 08-20-2006, 04:19 PM
  3. Base converter libary
    By cdonlan in forum C++ Programming
    Replies: 22
    Last Post: 05-15-2005, 02:11 AM
  4. dos game help
    By kwm32 in forum Game Programming
    Replies: 7
    Last Post: 03-28-2004, 06:28 PM
  5. formatting output
    By spliff in forum C Programming
    Replies: 2
    Last Post: 08-14-2001, 07:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21