Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define EPS 1e-7;
  3. using namespace std;
  4. const int N = 100;
  5. int a[N][N];
  6. int main ()
  7. {  
  8.     int n, m, i, j, c = 0, t = 1;
  9.     cin >> n >> m;
  10.     for ( i = 1; i <= n; i ++ )
  11.         {
  12.             for ( j = 1; j <= m;  j ++ )
  13.                 {
  14.                     a[i][j] = t;
  15.                     t ++;
  16.                 }
  17.         }
  18.     for ( i = 1; i <= n; i ++ )
  19.         {
  20.             if ( i % 2 == 0 )
  21.             for ( j = m; j >= 1;  j -- )
  22.                 {
  23.                     cout << a[i][j] <<" ";
  24.                 }
  25.             else
  26.             for ( j = 1; j <= m;  j ++ )
  27.                 {
  28.                     cout << a[i][j] <<" ";
  29.                 }
  30.             cout << endl;
  31.         }
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement