码迷,mamicode.com
首页 > 其他好文 > 详细

旋转图像

时间:2015-04-20 12:54:44      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

#include<stdio.h>
#include<string.h>
#define N 60
int n, m;
 
void slove1(char s[][60])
{
    int i, j;
    for(i = 1; i <= n ; i++)
    {
        for(j = 1 ; j <= m ; j++)
            printf("%c", s[i][j]);
        printf("\n");
    }
}
void slove2(char s[][60])
{
    int i , j;
    for(j = 1 ; j <= m ; j++)
    {
        for(i = n ; i >= 1 ; i--)
            printf("%c", s[i][j]);
        printf("\n");
    }
}
 
void slove3(char s[][60])
{
    int i, j;
    for(i = n ; i >= 1 ; i--)
    {
        for(j = m ; j >= 1 ; j--)
            printf("%c", s[i][j]);
        printf("\n");
    }
}
 
void slove4(char s[][60])
{
    int i, j;
    for(j = m ; j >= 1 ; j--)
    {
        for(i = 1 ; i <= n ; i++)
            printf("%c", s[i][j]);
        printf("\n");
    }
}
int main()
{
    int t, i, j, x;
    char s[N][N];
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d%d", &n, &m);
        getchar();
        for(i = 1 ; i <= n ; i++)
        {
            for(j = 1 ; j <= m ; j++)
                scanf(" %c", &s[i][j]);
        }
        scanf("%d", &x);
        if(x == 0)
            slove1(s);
        else if(x == 90)
            slove2(s);
        else if(x == 180)
            slove3(s);
        else if(x == 270)
            slove4(s);
    }
    return 0;
}

 

旋转图像

标签:

原文地址:http://www.cnblogs.com/qq2424260747/p/4441146.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!