Thread: how to print this shape?

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    4

    how to print this shape?

    hi all,
    i am new here..
    and i need help..

    when we print this shape

    1
    2 3
    3 4 5
    4 5 6 7
    5 6 7 8 9
    6 7 8 9 10 11
    7 8 9 10 11 12 13
    8 9 10 11 12 13 14 15

    we print this program..
    Code:
    for(i=1;i<=8;i++)
    {
    k=i;
    for(j=1;j<=i;j++)
    {
    cout<<k;
    k++;
    }
    cout<<endl;
    }
    i have programed that
    but when my teacher ask me this one
    in this one i need help
    1
    5 3
    6 4 5
    7 5 6 7
    8 6 7 8 9
    7 8 9 10 11
    8 9 10 11 12 13
    9 10 11 12 13 14 15

    please help me...
    Last edited by Salem; 01-28-2010 at 11:51 AM. Reason: / not \ in the tags

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    It's hard to tell what your second shape looks like unless you put it in code tags to keep the spaces accurate. Is this what you meant?
    Code:
    1
    5  3
    6  4  5 
    7  5  6  7
    8  6  7  8  9
       7  8  9 10 11
       8  9 10 11 12 13
       9 10 11 12 13 14 15

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    4
    yes daved you can say that ..thank you

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    What have you tried so far? Or if you haven't started, what is your idea for solving that problem?

    I don't understand the pattern of the picture, so I'm not sure I can tell you where to start.

  5. #5
    Registered User
    Join Date
    Jan 2010
    Posts
    4
    i have tried to use if ..and no promise..and try to make it 2 shape and no results..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Towr of Hanoi move the disc
    By WatchTower in forum C Programming
    Replies: 9
    Last Post: 07-17-2009, 03:48 AM
  2. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  3. Scope And Parameter Passing
    By djwicks in forum C Programming
    Replies: 6
    Last Post: 03-28-2005, 08:26 PM
  4. Newbie- having trouble with functions
    By bnmwad in forum C Programming
    Replies: 7
    Last Post: 02-22-2005, 04:41 PM
  5. What kind of programs should I start writing?
    By Macabre in forum C++ Programming
    Replies: 23
    Last Post: 04-12-2003, 08:13 PM