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. ACM2031_进制转换(使用了递归,代码超少的啦!!)

    进制转换 Problem Description 输入一个十进制数N,将它转换成R进制数输出.   Input 输入数据包含多个测试实例,每个测试实例包含两个整数N(32位整数)和R(2<=R& ...

  2. Hadoop-MapReduce之自定义数据类型

    以下是自定义的一个数据类型,有两个属性,一个是名称,一个是开始点(可以理解为单词和单词的位置) MR程序就不写了,请看WordCount程序. package cn.genekang.hadoop.m ...

  3. 多IDC数据分布--MySQL多机房部署 - 学习笔记 - 51CTO技术博客

    多IDC数据分布--MySQL多机房部署 - 学习笔记 - 51CTO技术博客 多IDC数据分布--MySQL多机房部署

  4. Spock Proxy

    Spock Proxy undefined 服务网关_百度搜索 undefined 8月2日,深圳 | DockOne技术沙龙开始报名啦 - DockOne.io undefined 知道创宇爬虫题- ...

  5. mv、umask、chattr、lsattr命令

    mv命令行,即move 将文件移动到目录下 对文件或目录重命名 umask chattr 设置文件或目录的隐藏属性 lsattr显示文件或目录的隐藏属性 ls mv 1.txt aa ls cd aa ...

  6. Preferred Java way to ping a HTTP Url for availability

    I need a monitor class that regularly checks whether a given HTTP URL is available. I can take care ...

  7. nyoj 123 士兵杀敌(四) 树状数组【单点查询+区间修改】

    士兵杀敌(四) 时间限制:2000 ms  |  内存限制:65535 KB 难度:5   描述 南将军麾下有百万精兵,现已知共有M个士兵,编号为1~M,每次有任务的时候,总会有一批编号连在一起人请战 ...

  8. N对括号的合法组合

    递归实现,需要注意以下几点: 1. 递归终止条件 2. 递归递推关系式 这里实际上是一个排列问题,只是排列需要满足条件在每一次递归调用时左括号数不能少于右括号数. 还有一点需要特别注意,当推出递归调用 ...

  9. Java对象的强、软、弱和虚引用详解

    1.对象的强.软.弱和虚引用 转自:http://zhangjunhd.blog.51cto.com/113473/53092/ 在JDK 1.2以前的版本中,若一个对象不被任何变量引用,那么程序就无 ...

  10. 使用Inputstream读取文件

    在java中,能够使用InputStream对文件进行读取,就是字节流的输入.当读取文件内容进程序时,须要使用一个byte数组来进行存储,如此会有例如以下两个问题: 1.怎样建立合适大小的byte数组 ...