CCF 201512-3画图
2016-12-13 16:53
381 查看
//@start time: //@finish time: //@此处注意:行和列是反的 //@ /* 测试数据 16 13 9 0 3 1 12 1 0 12 1 12 3 0 12 3 6 3 0 6 3 6 9 0 6 9 12 9 0 12 9 12 11 0 12 11 3 11 0 3 11 3 1 1 4 2 C 16 13 8 0 3 1 12 1 0 12 1 12 3 0 12 3 6 3 0 6 3 6 9 0 6 9 12 9 0 12 9 12 11 0 12 11 3 11 0 3 11 3 1 */ #include<iostream> #include<cstring> #include<vector> #include<cmath> int m,n,q; char plot[102][102]; int flag[102][102]; void show(); void change(int x,int y,char c){ if((plot[x][y]==c)) return; if((plot[x][y]=='.')||(flag[x][y]==1)){ plot[x][y]=c; flag[x][y]=1; if(x+1<=n) change(x+1,y,c); if(y+1<=m) change(x,y+1,c); if(x-1>=0) change(x-1,y,c); if(y-1>=0) change(x,y-1,c); } } using namespace std; int main(){ memset(plot,'.',sizeof(plot)); memset(flag,0,sizeof(flag)); cin>>m>>n>>q; for(int i=0;i<q;i++){ int action; cin>>action; if(!action){////action=0 画线操作 int x1,y1,x2,y2; cin>>x1>>y1>>x2>>y2; int start,over; if(x1==x2){//画竖线 - - start=y1<y2?y1:y2; over=y2>y1?y2:y1; for(int a=start;a<=over;a++){ flag[a][x1]=0; if( plot[a][x1]=='-'|| plot[a][x1]=='+') plot[a][x1]='+'; else plot[a][x1]='|'; } } else {//y1=y2//画横线 | | start=x1>x2?x2:x1; over=x2>x1?x2:x1; for(int a=start;a<=over;a++){ flag[y1][a]=0; if( plot[y1][a]=='|'|| plot[y1][a]=='+') plot[y1][a]='+'; else plot[y1][a]='-'; } } } else{//action=1 填充操作 int x,y; char put; cin>>y>>x; cin>>put; change(x,y,put); } } show(); return 0; } void show(){ for(int i=n-1;i>-1;i--){ for(int j=0;j<m;j++){ cout<<plot[i][j]; } cout<<endl; } }
相关文章推荐
- CCF 201512-3 画图
- ccf csp 201512-3 画图 java
- ccf 201512-3 画图
- CCF 201512-3 画图
- CCF CSP 201512-3 画图(Java-90分)
- 201512-3 画图 ccf
- ccf真题-201512-3-画图AC题解
- CCF CSP 编程题目和解答-----试题名称:画图 -------201512-3
- CCF-201512-3 画图
- CCF 201512-3 画图 (DFS搜索+模拟)
- CCF CSP 201512-3 画图
- CCF 201512-3 画图 题解
- CCF-CSP 画图 JAVA 201512-3
- 【CCFCSP】201512-3 画图
- ccf 201512-3 画图
- CCF CSP 201512-3 画图
- CCF-画图
- CCF资格认证201512-3参考
- CCF资格认证201512-3参考
- CCF 201409-2 画图 (暴力)