Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n, m;
- cin >> n >> m;
- int mx[n][m];
- int cnt = 0;
- for (int i = 1; i <= n; ++i) {
- for (int j = (m - 1 + i % 2) % m; 0 <= j && j < m; j += (i % 2) * 2 - 1) {
- mx[i - 1][j] = ++cnt;
- }
- }
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < m; ++j) {
- cout << mx[i][j] << " ";
- }
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement