UVa 10267 Graphical Editor
来源:互联网 发布:达观数据 知乎 编辑:程序博客网 时间:2024/05/28 16:12
注意填充颜色判断,避免无限递归。
#include <cstdio>#include <iostream>#include <vector>#include <sstream>#include <string>using namespace std;char bmp[252][252];int M,N;//col,rowvoid ProcessC(string str){ for(int i=1;i<=M;i++) { for(int j=1;j<=N;j++) { bmp[j][i]='O'; } }}void ProcessI(string str){ string c; stringstream scin(str); scin>>c>>M>>N; ProcessC("C");}void ProcessL(string str){ char ch,c; int x,y; stringstream scin(str); scin>>ch>>x>>y>>c; bmp[y][x]=c;}void ProcessV(string str){ char ch,c; int x,y1,y2,temp; stringstream scin(str); scin>>ch>>x>>y1>>y2>>c; if(y2<y1) { temp=y1; y1=y2; y2=temp; } for(int i=y1;i<=y2;i++) bmp[i][x]=c;}void ProcessH(string str){ char ch,c; int x1,x2,y,temp; stringstream scin(str); scin>>ch>>x1>>x2>>y>>c; if(x2<x1) { temp=x1; x1=x2; x2=temp; } for(int i=x1;i<=x2;i++) bmp[y][i]=c;}void ProcessK(string str){ char ch,c; int x1,x2,y1,y2,temp; stringstream scin(str); scin>>ch>>x1>>y1>>x2>>y2>>c; for(int i=x1;i<=x2;i++) for(int j=y1;j<=y2;j++) bmp[j][i]=c;}void FillXYC(int x,int y,char oc,char c){ if(bmp[y][x]!=oc) return; bmp[y][x]=c; if(x-1>0) FillXYC(x-1,y,oc,c); if(x+1<=M) FillXYC(x+1,y,oc,c); if(0<y-1) FillXYC(x,y-1,oc,c); if(N>=y+1) FillXYC(x,y+1,oc,c);}void ProcessF(string str){ char ch,c,oc; int x,y; stringstream scin(str); scin>>ch>>x>>y>>c; oc=bmp[y][x]; if(oc!=c)FillXYC(x,y,oc,c);}void ProcessS(string str){ char ch; string name; stringstream scin(str); scin>>ch>>name; cout<<name<<endl; for(int i=1;i<=N;i++) { for(int j=1;j<=M;j++) { cout<<bmp[i][j]; } cout<<endl; }}int main(){ string cmd; char ch; while(1) { getline(cin,cmd); if(cmd.length()==0) continue; ch=cmd[0]; if(ch=='X') break; switch(ch) { case 'I'://C, L, V, H, K, F, S ProcessI(cmd); break; case 'C': ProcessC(cmd); break; case 'L': ProcessL(cmd); break; case 'V': ProcessV(cmd); break; case 'H': ProcessH(cmd); break; case 'K': ProcessK(cmd); break; case 'F': ProcessF(cmd); break; case 'S': ProcessS(cmd); break; default: break; } } return 0;}
0 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
- C++ const 的全面总结
- Servlet——Tomcat服务器
- 如何将<td>文字过长的部分变成省略号显示
- 关于宏的使用小总结
- openstack的临时存储后端
- UVa 10267 Graphical Editor
- TOP CODER SRM 611 DIV2
- 安装wxWidgets遭遇的两大关卡
- SQlite在PC和ARM上的编译移植
- python:open/文件操作
- boa的make错误解析
- HDU 4059 The Boss on Mars-矩阵+容斥
- WP7开发调用相机和选择相片任务
- 串口转WIFI