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