郑轻ACM 1733: 旋转图像

Description

Input

Output

Sample Input

22 3111000903 3111101111180

Sample Output

010101111101111


对所有的数据进行相应的旋转即可。
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#define mem(_, __) memset(_, __, sizeof(_));
const int maxn = 111;
 
using namespace std;
 
int a[maxn][maxn], T, n, m, angle;
char Map[maxn][maxn];
 
void rotate_90()
{
    // 先列后行
    for (int j = 1; j <= m; j ++)
    {
        for (int i = n; i >= 1; i --)
            cout << a[i][j];
        cout << endl;
    }
}
 
void rotate_180()
{
    // 先行后列
    for (int i = n; i >= 1; i --)
    {
        for (int j = m; j >= 1; j --)
            cout << a[i][j];
        cout << endl;
    }
}
 
void rotate_270()
{
    // 先列后行
    for (int j = m;j >= 1;j --)
    {
        for (int i = 1;i <= n;i ++)
            cout << a[i][j];
        cout << endl;
    }
}
 
int main()
{
    scanf("%d", &T);
    while (T --)
    {
        scanf("%d%d", &n, &m);
        for (int i = 1; i <= n; i ++)
        {
            scanf("%s", Map[i] + 1);
            for (int j = 1; j <= m; j ++)
                a[i][j] = Map[i][j] - '0';
        }
        scanf("%d", &angle);
        if (angle == 0)
        {
            // 不需要旋转,直接输出即可
            for (int i = 1; i <= n; i ++)
            {
                for (int j = 1; j <= m; j ++)
                    cout << a[i][j];
                cout << endl;
            }
        }
        else if (angle == 90)
            rotate_90();
        else if (angle == 180)
            rotate_180();
        else
            rotate_270();
    }
    return 0;
}
/*
4
2 3
123
456
0
2 3
123
456
90
2 3
123
456
180
2 3
123
456
270
*/
 
/**************************************************************
    Problem: 1733
    User: 17839192987
    Language: C++
    Result: Accepted
    Time:40 ms
    Memory:1428 kb
****************************************************************/



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值