guitar-player

print_matrix_form.cpp

Mar 30th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int matrix[3][3];
  6.  
  7. int main()
  8. {
  9.     // asigning values, I suppose this is done allready.
  10.  
  11.     for(int x=0;x<3;x++)
  12.     {
  13.         for(int y=0;y<3;y++)
  14.         {
  15.             matrix[x][y]=1;
  16.         }
  17.     }
  18.  
  19.     // showing the matrix on the screen
  20.  
  21.     for(int x=0;x<3;x++)  // loop 3 times for three lines
  22.     {
  23.         for(int y=0;y<3;y++)  // loop for the three elements on the line
  24.         {
  25.             cout<<matrix[x][y];  // display the current element out of the array
  26.         }
  27.     cout<<endl;  // when the inner loop is done, go to a new line
  28.     }
  29.     return 0;  // return 0 to the OS.
  30. }
Advertisement
Add Comment
Please, Sign In to add comment