Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <stdio.h>
- #define REP(var, start, end) for(int var = start; var < end; var++)
- using namespace std;
- int main()
- {
- unsigned int n, m;
- unsigned int iterationFiller = 1;
- scanf("%d %d", &n, &m);
- int array[n][m];
- //fill
- REP(x, 0, n)
- {
- REP(y, 0, m)
- {
- if (x % 2 != 0)
- {
- if (y % 2 == 0)
- {
- array[x][y] = 0;
- }
- else
- {
- array[x][y] = iterationFiller;
- ++iterationFiller;
- }
- }
- else
- {
- if (y % 2 == 0)
- {
- array[x][y] = iterationFiller;
- ++iterationFiller;
- }
- else
- {
- array[x][y] = 0;
- }
- }
- }
- }
- //print
- REP(x, 0, n)
- {
- REP(y, 0, m)
- {
- printf("%4d", array[x][y]);
- }
- cout<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement