Description



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.

Input



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.

Output



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.


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



#include <iostream>
#include<string>
using namespace std;
char str[255][255];
string name;
void print(int N,int M)
{
//cout<<name<<endl;
for(int i = 1;i<=N;i++)
{
for(int j = 1;j<=M;j++)
{
cout<<str[i][j];
}
cout<<endl;
}
for(int i = 1;i<=N;i++)
{
for(int j = 1;j<=M;j++)
{
str[i][j] = 'O';
}
}
}
int main()
{
char ch;
int X,Y,M,N;
int X0 ,Y1,Y2 ,X1,X2,Y0;
int x1,y1,x2,y2;
int XF,YF;
char CL,CV,CH,CK,CF;
char CF_0; while(cin>>ch&&ch!='X')
{ switch(ch)
{
case 'I':
cin>>M>>N;
for(int i = 1;i<=N;i++)
{
for(int j = 1;j<=M;j++)
{
str[i][j] = 'O';
}
}
break;
case 'C':
for(int i = 1;i<=M;i++)
{
for(int j = 1;j<=N;j++)
{
str[i][j] = 'O';
}
}
break;
case 'L':
cin>>X>>Y>>CL;
str[Y][X] = CL;
break;
case 'V':
cin>>X0>>Y1>>Y2>>CV;
for(int i = Y1;i<=Y2;i++)
{
str[i][X0] = CV;
}
break;
case 'H':
cin>>X1>>X2>>Y0>>CH;
for(int i = X1;i<=X2;i++)
{
str[Y0][i] = CH;
}
break;
case 'K':
cin>>x1>>y1>>x2>>y2>>CK;
for(int i = y1;i<=y2;i++)
{
for(int j = x1;j<=x2;j++)
str[i][j] = CK;
}
break;
case 'F':
cin>>XF>>YF>>CF;
CF_0=str[YF][XF];
for(int i = 1;i<=N;i++)
{
for(int j = 1;j<=M;j++)
{
if(str[i][j]==CF_0)
str[i][j] = CF;
}
}
break;
case 'S':
cin>>name;
cout<<name<<endl;
print(N,M);
default:
break;
}
} return 0;
}

这道题大概看懂意思后也就不难了,我觉得主要考察的应该是switch的流程控制吧。

//看题要仔细,题中是英文字母‘O’,而不是数字‘0’,我在这WA了好几次……


ACM YTU 《挑战编程》第一章 入门 Problem E: Graphical Editor的更多相关文章

  1. 烟大 Contest1024 - 《挑战编程》第一章:入门 Problem E: Graphical Editor(模拟控制台命令形式修改图形)

    Problem E: Graphical Editor Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 2  Solved: 2[Submit][Statu ...

  2. ACM YTU 挑战编程 字符串 Problem A: WERTYU

    Problem A: WERTYU Description A common typing error is to place yourhands on the keyboard one row to ...

  3. Windows核心编程第一章.错误处理

    Windows核心编程第一章,错误处理. 一丶错误处理 1.核心编程学习总结 不管是做逆向,开始做开发.在Windows下.你都需要看一下核心编程这本书.这本书确实写得很好.所以自己在学习这本书的同时 ...

  4. .NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划

    作者:依乐祝 原文地址:https://www.cnblogs.com/yilezhu/p/9977862.html 写在前面 千呼万唤始出来,首先,请允许我长吸一口气!真没想到一份来自28岁老程序员 ...

  5. net core体系-web应用程序-4asp.net core2.0 项目实战(CMS)-第一章 入门篇-开篇及总体规划

    .NET Core实战项目之CMS 第一章 入门篇-开篇及总体规划   原文地址:https://www.cnblogs.com/yilezhu/p/9977862.html 写在前面 千呼万唤始出来 ...

  6. Java学习笔记 第一章 入门<转>

    第一章 JAVA入门 一.基础常识 1.软件开发 什么是软件? 软件:一系列按照特定顺序组织的计算机数据和指令的集合 系统软件:DOS,Windows,Linux 应用软件:扫雷.QQ.迅雷 什么是开 ...

  7. Java 面向对象编程——第一章 初识Java

      第一章    初识Java 1.  什么是Java? Java是一种简单的.面向对象的.分布式的.解释的.安全的.可移植的.性能优异的多线程语言.它以其强安全性.平台无关性.硬件结构无关性.语言简 ...

  8. UNIX环境高级编程--第一章 UNIX基础知识

    第一章 UNIX基础知识 1.2 UNIX体系结构   从严格意义上说,可将操作系统定义为一种软件,它控制计算机硬件资源,提供程序运行环境.我们将这种软件称为内核(kernel),因为 它相对较小,且 ...

  9. 读高性能JavaScript编程 第一章

    草草的看完第一章,虽然看的是译文也是感觉涨姿势了, 我来总结一下: 由于 大多数浏览器都是 single process 处理 ui updatas and js execute 于是产生问题: js ...

随机推荐

  1. HDOJ/HDU 2203 亲和串(简单的判断~Java的indexOf()方法秒)

    Problem Description 人随着岁数的增长是越大越聪明还是越大越笨,这是一个值得全世界科学家思考的问题,同样的问题Eddy也一直在思考,因为他在很小的时候就知道亲和串如何判断了,但是发现 ...

  2. [ZETCODE]wxWidgets教程一:介紹

    本教程原文链接:http://zetcode.com/gui/wxwidgets/introduction/ 翻译:瓶哥 日期:2013年11月26日星期二 邮箱: 414236069@qq.com ...

  3. [zz] makefile中=和:=的区别

    转载自:http://www.cnblogs.com/wanqieddy/archive/2011/09/21/2184257.html 在Makefile中我们经常看到 = := ?= +=这几个赋 ...

  4. MySQL外键约束On Delete、On Update各取值的含义

    主键.外键和索引的区别?   主键 外键 索引 定义: 唯一标识一条记录,不能有重复的,不允许为空 表的外键是另一表的主键, 外键可以有重复的, 可以是空值 主索引(由关键字PRIMARY定义的索引) ...

  5. Asp.Net Design Pattern Studynotes -- Part1

    Asp.Net Design Pattern Studynotes -- Part1 let's start with an exampleto entry amazing OO world ! le ...

  6. 深入理解Fsync----JBD内核调试 专业打杂程序员 @github yy哥

    http://hustcat.github.io/ http://www.cnblogs.com/hustcat/p/3283955.html http://blog.sina.com.cn/s/ar ...

  7. Qt 国际化之二:多国语界面动态切换的实现

    第一步在你的pro里面加入 TRANSLATIONS = myexec_zh.ts (根据对应的ts文件修改)第二步用lupdate 操作pro 将要翻译的提取到ts文件 命令是 lupdate my ...

  8. WebService学习笔记系列(四)

    今天主要来看看服务端的编写及发布. 服务端的编写主要包括三个步骤: 1.编写一个接口,即SEI(server endpoint interface) 2.编写接口的实现类,即SIB (server i ...

  9. Android(java)学习笔记187:Android中操作XML数据(使用Pull解析器)

    1. Pull解析器的运行方式与 SAX 解析器相似.它提供了类似的事件,如:开始元素和结束元素事件,使用parser.next()可以进入下一个元素并触发相应事件.跟SAX不同的是, Pull解析器 ...

  10. CentOS 6.7配置Nginx 1.8负载均衡

    本教程使用Vultr的VPS搭建,准备三台VPS,一主两从 master - 45.32.90.100 slave1 - 45.32.92.47 slave2 - 45.32.89.205 1.编译安 ...