Advertisement
gilzean

Untitled

May 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #define NMax 105
  3. using namespace std;
  4.  
  5. int mat[NMax][NMax], H, W, colors, count, i, j;
  6. int main() {
  7. cin >> H >> W;
  8. cin >> colors;
  9. i = 1;
  10. j = 1;
  11. for (int color = 1; color <= colors; color++) {
  12. cin >> count;
  13. while (count) {
  14. mat[i][j] = color;
  15. if (i % 2 == 1) {
  16. i = (j == W) ? (i + 1) : i;
  17. j = (j < W) ? (j + 1) : W;
  18. } else {
  19. i = (j == 1) ? (i + 1) : i;
  20. j = (j > 1) ? (j - 1) : 1;
  21. }
  22. count--;
  23. }
  24. }
  25. for (int i = 1; i <= H ; i++) {
  26. for (int j = 1; j <= W; j++) {
  27. cout << mat[i][j] << ' ';
  28. }
  29. cout << '\n';
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement