CCF 201512-3画图
#include <iostream>
#include <string>
#include <memory.h>
#include <stack>
using namespace std;
int main()
{
int n,m,q,tag,x1,y1,x2,y2;
char c;
stack<pair<int,int> > s;
while(cin>>n){
cin>>m>>q;
char mp[m][n];
memset(mp,'.',sizeof(mp));
for(int i=0;i<q;i++){
cin>>tag>>x1>>y1;
if(tag==0){/**»Ïß*/
cin>>x2>>y2;
if(x1==x2){/**»ÊúÏß*/
for(int j=min(y1,y2);j<=max(y1,y2);j++){
if(mp[j][x1]=='.') mp[j][x1]='|';
else if(mp[j][x1]=='-') mp[j][x1]='+';
}
}
else if(y1==y2){/**»ºáÏß*/
for(int j=min(x1,x2);j<=max(x1,x2);j++){
if(mp[y1][j]=='.') mp[y1][j]='-';
else if(mp[y1][j]=='|') mp[y1][j]='+';
}
}
}
else if(tag==1){/**Ìî³ä*/
cin>>c;
pair<int,int> t;
s.push(make_pair(x1,y1));
while(!s.empty()){
t=s.top();s.pop();
if(mp[t.second][t.first]=='.') mp[t.second][t.first]=c;
if(t.first>0&&mp[t.second][t.first-1]=='.') s.push(make_pair(t.first-1,t.second));
if(t.first<n-1&&mp[t.second][t.first+1]=='.') s.push(make_pair(t.first+1,t.second));
if(t.second>0&&mp[t.second-1][t.first]=='.') s.push(make_pair(t.first,t.second-1));
if(t.second<m-1&&mp[t.second+1][t.first]=='.') s.push(make_pair(t.first,t.second+1));
}
}
}
for(int i=0;i<m;i++){
for(int j=0;j<n;j++)
cout<<mp[i][j];
cout<<endl;
}
}
return 0;
}