Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define NMax 105
- using namespace std;
- int mat[NMax][NMax], H, W, colors, count, i, j;
- int main() {
- cin >> H >> W;
- cin >> colors;
- i = 1;
- j = 1;
- for (int color = 1; color <= colors; color++) {
- cin >> count;
- while (count) {
- mat[i][j] = color;
- if (i % 2 == 1) {
- i = (j == W) ? (i + 1) : i;
- j = (j < W) ? (j + 1) : W;
- } else {
- i = (j == 1) ? (i + 1) : i;
- j = (j > 1) ? (j - 1) : 1;
- }
- count--;
- }
- }
- for (int i = 1; i <= H ; i++) {
- for (int j = 1; j <= W; j++) {
- cout << mat[i][j] << ' ';
- }
- cout << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement