#include <stdio.h>
#include <memory.h>
#define MAXSIZE 251
char IMAGE[MAXSIZE][MAXSIZE];
void swap(int *a,int *b)
{
int temp;
temp = *a;
*a = *b;
*b =temp;
}
void display(int m,int n)
{
int i,j;
for(i=1;i<=n;i++)
{
for(j=1;j<=m;j++)
{
printf("%c",IMAGE[i][j]);
}
printf("\n");
}
}
void L()
{
int x,y;
char color;
scanf("%d %d %c",&x,&y,&color);
IMAGE[y][x] = color;
}
void V()
{
int x,y1,y2;
int i;
char color;
scanf("%d %d %d %c",&x,&y1,&y2,&color);
if(y1>y2) swap(&y1,&y2);
for(i=y1;i<=y2;i++)
IMAGE[i][x] = color;
}
void H()
{
int x1,x2,y;
int i;
char color;
scanf("%d %d %d %c",&x1,&x2,&y,&color);
if(x1>x2) swap(&x1,&x2);
for(i=x1;i<=x2;i++)
IMAGE[y][i] = color;
}
void K()
{
int x1,x2,y1,y2;
int i,j;
char color;
scanf("%d %d %d %d %c",&x1,&y1,&x2,&y2,&color);
if(x1>x2) swap(&x1,&x2);
if(y1>y2) swap(&y1,&y2);
for(j=y1;j<=y2;j++)
{
for(i=x1;i<=x2;i++)
{
IMAGE[j][i] = color;
}
}
}
void Fill(int x,int y,int m,int n,char oldcolor,char color)
{
if(x<1 || y<1 || x>m || y>n) return;
if(IMAGE[y][x]!=oldcolor || oldcolor==color) return;
IMAGE[y][x] = color;
Fill(x-1,y,m,n,oldcolor,color);
Fill(x+1,y,m,n,oldcolor,color);
Fill(x,y+1,m,n,oldcolor,color);
Fill(x,y-1,m,n,oldcolor,color);
}
void F(int m,int n)
{
int x,y;
char color;
scanf("%d %d %c",&x,&y,&color);
Fill(x,y,m,n,IMAGE[y][x],color);
}
void S(int m,int n)
{
char name[100];
scanf("%s",&name);
printf("%s\n",name);
display(m,n);
}
int main()
{
char command;
int m=0,n=0;
while(scanf("%c",&command))
{
if(command=='X') break;
if(command!='I' && m==0 && n==0) continue;
switch(command)
{
case 'I':
scanf("%d %d",&m,&n);
if(m>MAXSIZE || n>MAXSIZE) break;
case 'C':memset(IMAGE,'O',sizeof(IMAGE));
break;
case 'L':L(); break;
case 'V':V(); break;
case 'H':H(); break;
case 'K':K(); break;
case 'F':F(m,n); break;
case 'S':S(m,n); break;
default:break;
}
}
return 0;
}
UVa 10267 Graphical Editor
最新推荐文章于 2018-02-22 09:12:06 发布