SHARE
TWEET

№12

a guest Oct 15th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #include <stdio.h>
  3. #define REP(var, start, end) for(int var = start; var < end; var++)
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.   unsigned int n, m;
  9.   unsigned int iterationFiller = 1;
  10.  
  11.   scanf("%d %d", &n, &m);
  12.   int array[n][m];
  13.  
  14.   //fill
  15.   REP(x, 0, n)
  16.   {
  17.     REP(y, 0, m)
  18.     {
  19.       if (x % 2 != 0)
  20.       {
  21.         if (y % 2 == 0)
  22.         {
  23.           array[x][y] = 0;
  24.         }
  25.         else
  26.         {
  27.           array[x][y] = iterationFiller;
  28.           ++iterationFiller;
  29.         }
  30.       }
  31.       else
  32.       {
  33.         if (y % 2 == 0)
  34.         {
  35.           array[x][y] = iterationFiller;
  36.           ++iterationFiller;
  37.         }
  38.         else
  39.         {
  40.           array[x][y] = 0;
  41.         }
  42.       }
  43.  
  44.  
  45.     }
  46.   }
  47.  
  48.   //print
  49.   REP(x, 0, n)
  50.   {
  51.     REP(y, 0, m)
  52.     {
  53.       printf("%4d", array[x][y]);
  54.     }
  55.     cout<<"\n";
  56.   }
  57.  
  58.   return 0;
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top