Guest User

Untitled

a guest
May 24th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <sstream>
  4. #include <algorithm>
  5.  
  6. #define us unsigned short
  7.  
  8. using namespace std;
  9.  
  10. int main ()
  11. {
  12. int m, n, a, b, c, d;
  13. char ch, color, exp[221], g[252][252];
  14. string fname;
  15.  
  16. while (cin.getline(exp, 20))
  17. {
  18. stringstream s(exp);
  19.  
  20. s >> ch;
  21.  
  22. if (ch == 'I')
  23. {
  24. s >> m >> n;
  25.  
  26. for (us i = 1; i <= n; i ++)
  27. {
  28. for (us j = 1; j <= m; j ++)
  29. {
  30. g[i][j] = '0';
  31. }
  32. }
  33. }
  34. else if (ch == 'C')
  35. {
  36. for (us i = 1; i <= n; i ++)
  37. {
  38. for (us j = 1; j <= m; j ++)
  39. {
  40. g[i][j] = '0';
  41. }
  42. }
  43. }
  44. else if (ch == 'S')
  45. {
  46. s >> fname;
  47. cout << fname << endl;
  48.  
  49. for (us i = 1; i <= n; i ++)
  50. {
  51. for (us j = 1; j <= m; j ++)
  52. {
  53. cout << g[i][j];
  54. }
  55. cout << endl;
  56. }
  57. }
  58. else if (ch == 'L')
  59. {
  60. s >> a >> b >> color;
  61. g[b][a] = color;
  62. }
  63. else if (ch == 'V')
  64. {
  65. s >> c >> a >> b >> color;
  66. int ma = max(a, b);
  67.  
  68. for (us j = min(a, b); j <= ma; j ++)
  69. {
  70. g[j][c] = color;
  71. }
  72. }
  73. else if (ch == 'H')
  74. {
  75. s >> a >> b >> c >> color;
  76. int ma = max(a, b);
  77.  
  78. for (us j = min(a, b); j <= ma; j ++)
  79. {
  80. g[c][j] = color;
  81. }
  82. }
  83. else if (ch == 'K')
  84. {
  85. s >> a >> b >> c >> d >> color;
  86.  
  87. for (us i = b; i <= d; i ++)
  88. {
  89. for (us j = a; j <= c; j ++)
  90. {
  91. g[i][j] = color;
  92. }
  93. }
  94. }
  95. else if (ch == 'F')
  96. {
  97. s >> a >> b >> color;
  98. char rf = g[b][a];
  99.  
  100. for (us i = 1; i <= n; i += 1)
  101. {
  102. for (us j = 1; j <= m; j += 1)
  103. {
  104. if (g[i][j] == rf)
  105. {
  106. g[i-1][j-1] = color;
  107. g[i-1][j] = color;
  108. g[i-1][j+1] = color;
  109.  
  110. g[i][j-1] = color;
  111. g[i][j] = color;
  112. g[i][j+1] = color;
  113.  
  114. g[i+1][j-1] = color;
  115. g[i+1][j] = color;
  116. g[i+1][j+1] = color;
  117. }
  118. }
  119. }
  120. }
  121. else if (ch == 'X')
  122. {
  123. break;
  124. }
  125. }
  126. return 0;
  127. }
Add Comment
Please, Sign In to add comment