Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <sstream>
- #include <algorithm>
- #define us unsigned short
- using namespace std;
- int main ()
- {
- int m, n, a, b, c, d;
- char ch, color, exp[221], g[252][252];
- string fname;
- while (cin.getline(exp, 20))
- {
- stringstream s(exp);
- s >> ch;
- if (ch == 'I')
- {
- s >> m >> n;
- for (us i = 1; i <= n; i ++)
- {
- for (us j = 1; j <= m; j ++)
- {
- g[i][j] = '0';
- }
- }
- }
- else if (ch == 'C')
- {
- for (us i = 1; i <= n; i ++)
- {
- for (us j = 1; j <= m; j ++)
- {
- g[i][j] = '0';
- }
- }
- }
- else if (ch == 'S')
- {
- s >> fname;
- cout << fname << endl;
- for (us i = 1; i <= n; i ++)
- {
- for (us j = 1; j <= m; j ++)
- {
- cout << g[i][j];
- }
- cout << endl;
- }
- }
- else if (ch == 'L')
- {
- s >> a >> b >> color;
- g[b][a] = color;
- }
- else if (ch == 'V')
- {
- s >> c >> a >> b >> color;
- int ma = max(a, b);
- for (us j = min(a, b); j <= ma; j ++)
- {
- g[j][c] = color;
- }
- }
- else if (ch == 'H')
- {
- s >> a >> b >> c >> color;
- int ma = max(a, b);
- for (us j = min(a, b); j <= ma; j ++)
- {
- g[c][j] = color;
- }
- }
- else if (ch == 'K')
- {
- s >> a >> b >> c >> d >> color;
- for (us i = b; i <= d; i ++)
- {
- for (us j = a; j <= c; j ++)
- {
- g[i][j] = color;
- }
- }
- }
- else if (ch == 'F')
- {
- s >> a >> b >> color;
- char rf = g[b][a];
- for (us i = 1; i <= n; i += 1)
- {
- for (us j = 1; j <= m; j += 1)
- {
- if (g[i][j] == rf)
- {
- g[i-1][j-1] = color;
- g[i-1][j] = color;
- g[i-1][j+1] = color;
- g[i][j-1] = color;
- g[i][j] = color;
- g[i][j+1] = color;
- g[i+1][j-1] = color;
- g[i+1][j] = color;
- g[i+1][j+1] = color;
- }
- }
- }
- }
- else if (ch == 'X')
- {
- break;
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment