Before the csdn on the code, ran down, found that the official first test is not a problem, but after the submission is 100 points, speculation is not used in the question system is the first Test example.
Another, before the code is 0 points, and later found that the characters are more than the output of space, the future is to seriously read the question.
After the last change, is 90 points, later by the person corrected, is not considered when the dash encountered ' + ' situation, whether it is painting ' | ' Or '-', you still have to keep ' + ' when you encounter ' + '.
Original: http://blog.csdn.net/jaster_wisdom/article/details/51059144
After the modified code, you can run through all the test examples.
#include <stdio.h>
#include <stdlib.h>
int n,m,q;
int do1_x,do1_y;
Char Do1_c;
int do0_x1,do0_x2,do0_y1,do0_y2;
Char flag[100][100];
int draw1 (int x,int Y,char c)
{
if (x < 0 | | x >= N)
{
return 0;
}
if (Y < 0 | | y >= m)
{
return 0;
}
if (flag[x][y] = = ' + ' | | flag[x][y] = = '-' | | flag[x][y] = = ' | ')
{
return 0;
}
else if (flag[x][y] = = c)
{
return 0;
}
Else
{
Flag[x][y] = c;
DRAW1 (X+1,Y,C);
DRAW1 (X-1,Y,C);
DRAW1 (X,Y+1,C);
DRAW1 (X,Y-1,C);
}
return 0;
}
int draw0 (int x1,int y1,int x2,int y2)
{
int t;
int i;
if (x1 = = x2)
{
if (y1 > y2)
{
t = y2;
y2 = y1;
y1 = t;
}
for (i = Y1;i <= y2; i++)
{
if (flag[x1][i] = = ' | ')
{
Flag[x1][i] = ' + ';
}
else if (flag[x1][i] = = ' + ')
{
Continue
}
Else
{
Flag[x1][i] = '-';
}
}
}
else if (y1 = = y2)
{
if (X1 > x2)
{
t = x2;
x2 = x1;
x1 = t;
}
for (i = x1;i <= x2;i++)
{
if (flag[i][y1] = = '-')
{
Flag[i][y1] = ' + ';
}
else if (flag[i][y1] = = ' + ')
{
Continue
}
Else
{
FLAG[I][Y1] = ' | ';
}
}
}
Else
{
printf ("Error:x1! = x2 && Y1! = y2\n");
}
return 0;
}
int initial ()
{
int i,j;
for (i=0;i<100;i++)
{
for (j=0;j<100;j++)
{
FLAG[I][J] = '. ';
}
}
return 0;
}
int Read_draw ()
{
int i;
int mark;
scanf ("%d%d%d", &m,&n,&q);
for (i=0;i<q;i++)
{
scanf ("%d", &mark);
if (Mark = = 1)
{
scanf ("%d%d%c", &do1_y,&do1_x,&do1_c);
DRAW1 (Do1_x,do1_y,do1_c);
}
Else
{
scanf ("%d%d%d%d", &do0_y1,&do0_x1,&do0_y2,&do0_x2);
Draw0 (DO0_X1,DO0_Y1,DO0_X2,DO0_Y2);
}
}
return 0;
}
int pri ()
{
int i,j;
for (i=n-1;i>=0;i--)
{
if (i! = (n-1))
{
printf ("\ n");
}
for (j=0;j<m;j++)
{
printf ("%c", Flag[i][j]);
}
}
return 0;
}
int main ()
{
Initial ();
Read_draw ();
PRI ();
return 0;
}
Sixth session of CCF computer Professional Qualification Examination (third question) (drawing)