Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main()
- {
- ll r, c;
- cin >> r >> c; //r= number of rows, c=number of colums
- int a[r][c];
- for (ll i = 0; i < r; i++)
- {
- for (ll j = 0; j < c; j++)
- {
- cin >> a[i][j];
- }
- }
- for (ll j = 0; j < c; j++)
- {
- //if j is odd --> go up
- if (j % 2)
- {
- for (ll i = r - 1; i >= 0; i--)
- {
- cout << a[i][j] << ",";
- }
- }
- else
- {
- for (ll i = 0; i < r; i++)
- {
- cout << a[i][j] << ",";
- }
- }
- }
- cout << "END";
- return 0;
- }
- /*
- sample input:
- 4 4
- 11 12 13 14
- 21 22 23 24
- 31 32 33 34
- 41 42 43 44
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement