Docsity

Interactive Graphical Editor Program: Commands and Functionality, Ejercicios de Programación C

Toggle sidebar
bg1
The simple graphical editor deals with a rectangular table M×N(1 ≤M, N ≤250). Each pixel of
the table has its colour. The picture is formed from this square pixels.
The problem is to write a program, which simulates an interactive work of the graphical editor.
Input
Input consists of the editor commands, one per line. Each command is represented by one Latin capital
placed in the very beginning of the line. If the command supposes parameters, all the parameters will
be given in the same line separated by space. As the parameters there may be: the coordinates of the
pixel - two integers, the first one is the column number and belongs to 1 . . . M , the second one is the
row number and belongs to 1 . . . N, the origin is in the upper left corner of the table; the colour - the
Latin capital; file name - in MSDOS 8.3 format.
The editor deals with the following commands:
IM N Creates a new table M×N. All the pixels are colored in white (O).
CClears the table. The size remains the same. All the pixels became
white (O).
LX Y C Colors the pixel with coordinates (X, Y ) in colour C.
VX Y1Y2CDraws the vertical segment in the column Xbetween the rows Y1
and Y2inclusive in colour C.
HX1X2Y C Draws the horizontal segment in the row Ybetween the columns
X1and X2inclusive in colour C.
KX1Y1X2Y2CDraws the filled rectangle in colour C. (X1, Y1) is the upper left
corner, (X2, Y2) is the lower right corner of the rectangle.
FX Y C Fills the region with the colour C. The region Rto be filled is
defined as follows. The pixel (X, Y ) belongs to this region. The
other pixel belongs to the region Rif and only if it has the same
colour as pixel (X, Y ) and a common side with any pixel which
belongs to this region.
SName Writes the picture in the file Name.
XTerminates the session.
Output
Every time the command ‘SNAM E’ meets, you should output the file name N AME and the current
table, row by row. Each row is represented by a pixels’ colours series, see the output sample.
Errors: If as a command there will be a character different from I, C, L, V, H, K, F, S, X, the
editor should ignore the whole line and pass to the next command.
In case of other errors the program behaviour is unpredictable.
Sample Input
I56
L23A
S one.bmp
G23J
F33J
V234W
H342Z
S two.bmp
X
Sample Output
one.bmp
OOOOO
OOOOO
OAOOO
OOOOO
OOOOO
OOOOO
two.bmp
JJJJJ
JJZZJ
JWJJJ
JWJJJ
JJJJJ
JJJJJ

Vista previa parcial del texto

¡Descarga Interactive Graphical Editor Program: Commands and Functionality y más Ejercicios en PDF de Programación C solo en Docsity!

The simple graphical editor deals with a rectangular table M × N (1 ≤ M, N ≤ 250). Each pixel of the table has its colour. The picture is formed from this square pixels. The problem is to write a program, which simulates an interactive work of the graphical editor.

Input

Input consists of the editor commands, one per line. Each command is represented by one Latin capital placed in the very beginning of the line. If the command supposes parameters, all the parameters will be given in the same line separated by space. As the parameters there may be: the coordinates of the pixel - two integers, the rst one is the column number and belongs to 1... M , the second one is the row number and belongs to 1... N , the origin is in the upper left corner of the table; the colour - the Latin capital; le name - in MSDOS 8.3 format. The editor deals with the following commands:

I M N Creates a new table M × N. All the pixels are colored in white (O). C Clears the table. The size remains the same. All the pixels became white (O). L X Y C Colors the pixel with coordinates (X, Y ) in colour C. V X Y 1 Y 2 C Draws the vertical segment in the column X between the rows Y 1 and Y 2 inclusive in colour C. H X 1 X 2 Y C Draws the horizontal segment in the row Y between the columns X 1 and X 2 inclusive in colour C. K X 1 Y 1 X 2 Y 2 C Draws the lled rectangle in colour C. (X 1 , Y 1 ) is the upper left corner, (X 2 , Y 2 ) is the lower right corner of the rectangle. F X Y C Fills the region with the colour C. The region R to be lled is de ned as follows. The pixel (X, Y ) belongs to this region. The other pixel belongs to the region R if and only if it has the same colour as pixel (X, Y ) and a common side with any pixel which belongs to this region. S N ame Writes the picture in the le N ame. X Terminates the session.

Output

Every time the command `S N AM E' meets, you should output the le name N AM E and the current table, row by row. Each row is represented by a pixels' colours series, see the output sample.

Errors: If as a command there will be a character different from I, C, L, V, H, K, F, S, X, the editor should ignore the whole line and pass to the next command. In case of other errors the program behaviour is unpredictable.

Sample Input

I 5 6

L 2 3 A

S one.bmp G 2 3 J F 3 3 J V 2 3 4 W H 3 4 2 Z S two.bmp X

Sample Output

one.bmp OOOOO OOOOO OAOOO OOOOO OOOOO OOOOO two.bmp JJJJJ JJZZJ JWJJJ JWJJJ JJJJJ JJJJJ