Advertisement
paradox64ce

TheWireUs-Day1

Sep 18th, 2020
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     ll r, c;
  10.     cin >> r >> c; //r= number of rows, c=number of colums
  11.     int a[r][c];
  12.     for (ll i = 0; i < r; i++)
  13.     {
  14.         for (ll j = 0; j < c; j++)
  15.         {
  16.             cin >> a[i][j];
  17.         }
  18.     }
  19.  
  20.     for (ll j = 0; j < c; j++)
  21.     {
  22.         //if j is odd --> go up
  23.         if (j % 2)
  24.         {
  25.             for (ll i = r - 1; i >= 0; i--)
  26.             {
  27.                 cout << a[i][j] << ",";
  28.             }
  29.         }
  30.         else
  31.         {
  32.             for (ll i = 0; i < r; i++)
  33.             {
  34.                 cout << a[i][j] << ",";
  35.             }
  36.         }
  37.     }
  38.     cout << "END";
  39.     return 0;
  40. }
  41. /*
  42. sample input:
  43. 4 4
  44. 11 12 13 14
  45. 21 22 23 24
  46. 31 32 33 34
  47. 41 42 43 44
  48. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement