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. vijosP1687 细菌总数

    vijosP1687 细菌总数 链接:https://vijos.org/p/1687 [思路] 错排公式+高精度. 题目要求排列数目而且不能有Pi==i的情况出现,可以看出这正是1,2,3,4,5, ...

  2. The File's Owner

    The File Owner is an instantiated, runtime object that owns the contents of your nib and its outlets ...

  3. “互联网+”引发IT人才招工荒-新华网安徽频道

    "互联网+"引发IT人才招工荒-新华网安徽频道 "互联网+"引发IT人才招工荒

  4. Ubuntu vim+ ctags(包含系统函数) + taglist 配置 分类: vim ubuntu 2015-06-09 18:19 195人阅读 评论(0) 收藏

    阅读大型代码,我们经常需要打开很多的代码文件,搜索各种定义.windows下用惯了ide的朋友,转战Linux的时候可能会觉得很难受,找不到合适的阅读工具.其实万能的vim就可以实现.下面介绍一下vi ...

  5. 经典SQL语句大全之数据开发

    数据开发 1.按姓氏笔画排序:Select * From TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as //从少到多 ...

  6. LabVIEW设计模式系列——功能全局变量

    标准化:1.图标的标准化         2.模式的标准化Operation:Write & Read        3.xx为变量名称,w为write括号中为默认值,r为read       ...

  7. Linux多网卡多IP配置

    echo "210 local100" >> /etc/iproute2/rt_tables echo "220 local200" >> ...

  8. RedHat7上安装MariaDB

    编译安装MariaDB 下载MariaDB# wget http://mirrors.opencas.cn/mariadb//mariadb-10.1.8/source/mariadb-10.1.8. ...

  9. MYSQL 基础操作

    1.MySQL基础操作 一:MySQL基础操作 1:MySQL表复制 复制表结构 + 复制表数据 create table t3 like t1; --创建一个和t1一样的表,用like(表结构也一样 ...

  10. MYSQL批处理

    待更新 版权声明:本文为博主原创文章,未经博主允许不得转载.