Guest User

Untitled

a guest
Apr 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. /*  Michael Brosh ID 304138738
  2.     Assignment 5, Ex. 1-6
  3.     Due date: 06.12.11  */
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. const  int  ROWS    = 8;
  9. const  int  COLS    = 5;
  10.  
  11. void main()
  12. {
  13.    
  14.     int  i, j, matrix[ROWS][COLS];
  15.     int  value = 1;
  16.  
  17.     for (j = COLS - 1 ; j >= 0 ; j--)
  18.     {
  19.         if (j % 2 == 0)
  20.         {
  21.             for (i = 0 ; i < ROWS ; i++)
  22.                 matrix[i][j] = value++;
  23.         }
  24.         else
  25.         {
  26.             for (i = ROWS - 1 ; i >= 0 ; i--)
  27.                 matrix[i][j] = value++;
  28.         }
  29.      
  30.     }
  31.  
  32.         for (i = 0 ; i < ROWS ; i++)
  33.         {
  34.             for (j = 0 ; j < COLS ; j++)
  35.                 cout << matrix[i][j] << "\t";
  36.             cout << "\n";
  37.         }
  38.    
  39.     system("pause");
  40.  
  41.     cout << "\n";
  42. }
  43.  
  44. /*
  45.  
  46. Output:
  47.  
  48. 33      32      17      16      1
  49. 34      31      18      15      2
  50. 35      30      19      14      3
  51. 36      29      20      13      4
  52. 37      28      21      12      5
  53. 38      27      22      11      6
  54. 39      26      23      10      7
  55. 40      25      24      9       8
  56. Press any key to continue . . .
  57.  
  58. */
  59.  
  60. // I can't believe that I succeeded this hell of a targil!!!! :)
Add Comment
Please, Sign In to add comment