A. Rotate, Flip and Zoom(VK Cup 2015 - Qualification Round 2 简单模拟)

本文介绍了一种图像编辑器的基本变换功能实现方法,包括顺时针旋转90度、水平翻转及放大两倍等操作,并通过具体示例展示了如何处理黑白图像。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Rotate, Flip and Zoom
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Polycarp is writing the prototype of a graphic editor. He has already made up his mind that the basic image transformations in his editor will be: rotate the image 90 degrees clockwise, flip the image horizontally (symmetry relative to the vertical line, that is, the right part of the image moves to the left, and vice versa) and zooming on the image. He is sure that that there is a large number of transformations that can be expressed through these three.

He has recently stopped implementing all three transformations for monochrome images. To test this feature, he asked you to write a code that will consecutively perform three actions with a monochrome image: first it will rotate the image 90 degrees clockwise, then it will flip the image horizontally and finally, it will zoom in twice on the image (that is, it will double all the linear sizes).

Implement this feature to help Polycarp test his editor.

Input

The first line contains two integers, w and h (1 ≤ w, h ≤ 100) — the width and height of an image in pixels. The picture is given in hlines, each line contains w characters — each character encodes the color of the corresponding pixel of the image. The line consists only of characters "." and "*", as the image is monochrome.

Output

Print 2w lines, each containing 2h characters — the result of consecutive implementing of the three transformations, described above.

Sample test(s)
input
3 2
.*.
.*.
output
....
....
****
****
....
....
input
9 20
**.......
****.....
******...
*******..
..******.
....****.
......***
*.....***
*********
*********
*********
*********
....**...
...****..
..******.
.********
****..***
***...***
**.....**
*.......*
output
********......**********........********
********......**********........********
********........********......********..
********........********......********..
..********......********....********....
..********......********....********....
..********......********..********......
..********......********..********......
....********....****************........
....********....****************........
....********....****************........
....********....****************........
......******************..**********....
......******************..**********....
........****************....**********..
........****************....**********..
............************......**********
............************......**********





#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>

using namespace std;

char map[210][210];
char mm[210][210];
int n,m;

int main()
{
    while(scanf("%d%d",&m,&n)!=EOF)
    {
        for(int i=0;i<n;i++)
        {
            scanf("%s",mm[i]);
        }
        for(int i=0;i<m;i++)
        {
            int k = 0;
            for(int j=n-1;j>=0;j--)
            {
                map[i][k++] = mm[j][i];
            }
            map[i][k] = '\0';
        }
        for(int i=0;i<m;i++)
        {
            for(int j=n-1;j>=0;j--)
            {
                printf("%c%c",map[i][j],map[i][j]);
            }
            printf("\n");
            for(int j=n-1;j>=0;j--)
            {
                printf("%c%c",map[i][j],map[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

叶孤心丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值