Graphical Editor

2020年1月17日 1236点热度 0人点赞 0条评论

Graphical Editor

时间: 1ms        内存:64M

描述:

Graphical editors such as Photoshop allow us to alter bit-mapped images in the same way that text editors allow us to modify documents. Images are represented as an M x N array of pixels, where each pixel has a given color.

Your task is to write a program which simulates a simple interactive graphical editor.

输入:

The input consists of a sequence of editor commands, one per line. Each command is represented by one capital letter placed as the first character of the line. If the command needs parameters, they will be given on the same line separated by spaces.

Pixel coordinates are represented by two integers, a column number between 1...M and a row number between 1...N, where 1M, N250. The origin sits in the upper-left corner of the table. Colors are specified by capital letters.

I M N Create a new

M x N image with all pixels initially colored
white (O).

C Clear the table by setting all pixels white (O).
The size remains unchanged.
L X Y C Colors the pixel (X, Y) in color (C).
V X Y1 Y2 C Draw a vertical segment of color (C) in column X, between
the rows Y1 and Y2 inclusive.
H X1 X2 Y C Draw a horizontal segment of color (C) in the row Y, between
the columns X1 and X2 inclusive.
K X1 Y1 X2 Y2 C Draw a filled rectangle of color C, where
(X1, Y1) is the upper-left and (X2, Y2) the lower right corner.
F X Y C Fill the region R with the color C, where R is
defined as follows.
Pixel (X, Y) belongs to R.
Any other pixel
which is
the same color
as pixel (X, Y) and shares a common side with any
pixel in R also belongs to this region.
S Name Write the file name in MSDOS 8.3 format followed by the
contents of the current image.
X Terminate the session.

输出:

On every command S NAME, print the filename NAME and contents of the current image. Each row is represented by the color contents of each pixel. See the sample output.

Ignore the entire line of any command defined by a character other than I, C, L, V, H, K, F, S, or X, and pass on to the next command. In case of other errors, the program behavior is unpredictable.

示例输入:

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

示例输出:

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

提示:

参考答案:

解锁文章

没有看到答案?微信扫描二维码可免费解锁文章

微信扫描二维码解锁

使用微信扫描二维码打开广告页面后可以立即关闭,再刷新此页面即可正常浏览此文章

所跳转广告均由第三方提供,并不代表本站观点!

已经扫描此二维码?点此立即跳转

code

这个人很懒,什么都没留下

文章评论