Matrix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rpapaiof
    New Member
    • Oct 2006
    • 27

    Matrix

    please i have to write a program that print this form
    1 2 3 4 5
    2 3 4 5
    3 4 5
    4 5
    5



    and other one this form

    5 4 3 2 1
    4 3 2 1
    3 2 1
    2 1
    1
    my program print only ones
  • dush
    New Member
    • Sep 2006
    • 27

    #2
    Hi,

    first code:
    Code:
    int i, j = 1;
    while (i = j, j++ <= 5) 
    {  
      while (i <= 5)
        cout << i++ << " ";   
      cout << endl;
    }
    second code:
    Code:
    int i, j = 5;
    while (i = j--)
    {
      while (i)
        cout << i-- << " ";      
      cout << endl;
    }

    Comment

    Working...