#include<stdio.h>
char s[100][100], c;
int main()
{
void stuff(char s[][100], int a, int b, char c, int m, int n);
int m, n, q,i,j,a,b,x1,x2,y1,y2,flag;
scanf_s("%d%d%d", &m, &n, &q);//a为宽,b为高
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
s[i][j] = '.';
}
//以左上角为(0,0)
for (i = 1; i <= q; i++)
{
scanf_s("%d", &flag);
if (flag)
{
scanf_s("%d%d", &a, &b);
getchar();
c = getchar();
stuff(s, a, b, c, m, n);
}//填充
else
{
scanf_s("%d%d%d%d", &x1, &y1, &x2, &y2);
if (y1==y2)//纵坐标相等
{
if (x1 > x2)//保证x1<=x2
{
int t;
t = x1, x1 = x2, x2 = t;
}
for (j = x1; j <= x2; j++)
{
if (s[j][y1] == '|')
s[j][y1] = '+';
else
s[j][y1] = '-';
}
}
else if (x1==x2)//横坐标相等
{
if (y1 > y2)//保证y1<=y2
{
int t;
t = y1, y1 = y2, y2 = t;
}
for (j = y1; j <= y2; j++)
{
if (s[x1][j] == '-')
s[x1][j] = '+';
else
s[x1][j] = '|';
}
}
}//画线
}
for (i=n-1; i>=0; i--)
{
for (j = 0; j < m; j++)
{
printf("%c", s[i][j]);
}
printf("\n");
}
return 0;
}
void stuff(char s[][100], int a, int b, char c, int m, int n)
{
int i;
int r[100],t[100];
for (i = 0; i < 100; i++)
{
r[i] = i;
t[i] = i;
}
s[a][b] = c;//????
if (a + 1 < m && s[a + 1][b] != '|' && s[a + 1][b] != '+' && s[a + 1][b] != '-')//向右填充
stuff(s, r[a+1], b, c, m, n);
if (a - 1 >=0 && s[a - 1][b] != '|' && s[a - 1][b] != '+' && s[a - 1][b] != '-')//向左填充
stuff(s, r[a - 1], b, c, m, n);
if (b + 1 < n && s[a][b + 1] != '|' && s[a][b + 1] != '+' && s[a][b + 1] != '-')
stuff(s, a, t[b + 1], c, m, n);
if (b - 1 >=0 && s[a][b - 1] != '|' && s[a][b - 1] != '+' && s[a][b - 1] != '-')
stuff(s, a, t[b - 1], c, m, n);
return;
}
##CSP 201512-3 画图(C语言)
猜你喜欢
转载自blog.csdn.net/weixin_45884316/article/details/103465968
今日推荐
周排行