UVa 10267-Graphical Editor
来源:互联网 发布:手办 邪神 知乎 编辑:程序博客网 时间:2024/06/05 17:33
简单的模拟+DFS题,注意初始化时像素为大写字母‘O’,而不是数字‘0’。还有就是注意需要保证 x1 < x2, y1 < y2。
代码如下:
#include <iostream>#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>using namespace std;int m, n, vis[252][252];char a[252][252], c, cc;void change(int &x, int &y){ if(x > y) { int t = x; x = y; y = t; }}void DFS(int x, int y){ if(x < 1 || y < 1 || x > m || y > n || vis[y][x] || a[y][x] != cc) return ; a[y][x] = c; vis[y][x] = 1; DFS(x + 1, y); DFS(x - 1, y); DFS(x, y + 1); DFS(x, y - 1);}int main(){#ifdef test freopen("sample.txt", "r", stdin);#endif int x1, x2, y1, y2; char name[50], b[3], bb[3]; while(1) { scanf("%s", b); if(b[0] == 'X') break; else if(b[0] == 'I') { scanf("%d%d", &m, &n); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) a[i][j] = 'O'; } else if(b[0] == 'C') for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) a[i][j] = 'O'; else if(b[0] == 'L') { scanf("%d%d%s", &x1, &y1, bb); a[y1][x1] = bb[0]; } else if(b[0] == 'V') { scanf("%d%d%d%s", &x1, &y1, &y2, bb); change(y1, y2); for(int i = y1; i <= y2; i++) a[i][x1] = bb[0]; } else if(b[0] == 'H') { scanf("%d%d%d%s", &x1, &x2, &y1, bb); change(x1, x2); for(int i = x1; i <= x2; i++) a[y1][i] = bb[0]; } else if(b[0] == 'K') { scanf("%d%d%d%d%s", &x1, &y1, &x2, &y2, bb); change(x1, x2); change(y1, y2); for(int i = y1; i <= y2; i++) for(int j = x1; j <= x2; j++) a[i][j] = bb[0]; } else if(b[0] == 'F') { scanf("%d%d%s", &x1, &y1, bb); c = bb[0]; cc = a[y1][x1]; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) vis[i][j] = 0; DFS(x1, y1); } else if(b[0] == 'S') { scanf("%s", name); puts(name); for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) printf("%c", a[i][j]); printf("\n"); } } } return 0;}
- uva-10267 - Graphical Editor
- UVa 10267-Graphical Editor
- uva 10267 Graphical Editor
- UVA 10267 - Graphical Editor
- UVa 10267 Graphical Editor
- UVa 10267 Graphical Editor
- UVa 10267 Graphical Editor
- UVa OJ 10267Graphical Editor
- UVa Problem Solution: 10267 - Graphical Editor
- 简单模拟 UVa 10267 - Graphical Editor
- UVa 10267 Problem: Graphical Editor (PC 110105)
- 10267 - Graphical Editor
- 10267 - Graphical Editor
- UVa Problem 10267 Graphical Editor (图形化编辑器)
- UVa Problem 10267 Graphical Editor (图形化编辑器)
- PC/Uva 11015/10267 图形编辑器(Graphical Editor)
- Graphical Editor
- 110105 Graphical Editor
- VS2008,断点停不下来的问题的总结
- c++引入mysql头文件
- UML
- c语言 正则表达式可编译c文件
- VC++实现遍历所有进程的TCP与UDP链接
- UVa 10267-Graphical Editor
- H264 Over RTP
- 算法之美——求解 字符串间最短距离(动态规划)
- VC++实现IP与ARP信息获取,可以同理实现APR攻击
- Android编译大全
- 如何成为一个出色的网站架构师
- Thrift入门教程
- jQuery的图片/文字无缝滚动
- android驱动