http://acm.hdu.edu.cn/showproblem.php?pid=2135

Problem Description
After the 32nd ACM/ICPC regional contest, Wiskey is beginning to prepare for CET-6. He has an English words table and read it every morning.
One day, Wiskey's chum wants to play a joke on him. He rolling the table, and tell Wiskey how many time he rotated. Rotate 90 degrees clockwise or count-clockwise each time.
The table has n*n grids. Your task is tell Wiskey the final status of the table.
 
Input
Each line will contain two number.
The first is postive integer n (0 < n <= 10).
The seconed is signed 32-bit integer m.
if m is postive, it represent rotate clockwise m times, else it represent rotate count-clockwise -m times.
Following n lines. Every line contain n characters.
 
Output
Output the n*n grids of the final status.
 
Sample Input
3 2
123
456
789
3 -1
123
456
789
 
Sample Output
987
654
321
369
258
147
 
代码:

#include <bits/stdc++.h>
using namespace std; int N, M;
char mp[15][15]; int main() {
while(~scanf("%d%d", &N, &M)) {
int flag;
if(M > 0) flag = 1;
else flag = 0;
memset(mp, 0, sizeof(mp));
for(int i = 1; i <= N; i ++) {
getchar();
for(int j = 1; j <= N; j ++)
scanf("%c", &mp[i][j]);
} if(abs(M) % 4 == 0) {
for(int i = 1; i <= N; i ++) {
for(int j = 1; j <= N; j ++)
printf("%c", mp[i][j]);
printf("\n");
}
} else {
if(abs(M) % 4 == 2) {
for(int i = N; i >= 1; i --) {
for(int j = N; j >= 1; j --)
printf("%c", mp[i][j]);
printf("\n");
}
} else if(M > 0 && M % 4 == 1 || M < 0 && abs(M) % 4 == 3) {
for(int j = 1; j <= N; j ++) {
for(int i = N; i >= 1; i --)
printf("%c", mp[i][j]);
printf("\n");
}
} else if(M > 0 && M % 4 == 3 || M < 0 && abs(M) % 4 == 1) {
for(int j = N; j >= 1; j --) {
for(int i = 1; i <= N; i ++)
printf("%c", mp[i][j]);
printf("\n");
}
}
}
}
return 0;
}

  

HDU 2135 Rolling table的更多相关文章

  1. HDOJ(HDU) 2135 Rolling table

    Problem Description After the 32nd ACM/ICPC regional contest, Wiskey is beginning to prepare for CET ...

  2. HDU 4951 Multiplication table 阅读题

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4951 题意:给一个P进制的乘法表.行和列分别代表0~p-1,第i行第j*2+1和第j*2+2列代表的是第i ...

  3. HDU 4951 Multiplication table(2014 Multi-University Training Contest 8)

    思路   如果进制为p    那么当x<p时 (p-1)*(p-x)=(p-(x+1))  *p +x     因为x<p  所以没有进位  所以高位上的数字为    p-(x+1). 根 ...

  4. POJ 2135 Farm Tour &amp;&amp; HDU 2686 Matrix &amp;&amp; HDU 3376 Matrix Again 费用流求来回最短路

    累了就要写题解,近期总是被虐到没脾气. 来回最短路问题貌似也能够用DP来搞.只是拿费用流还是非常方便的. 能够转化成求满流为2 的最小花费.一般做法为拆点,对于 i 拆为2*i 和 2*i+1.然后连 ...

  5. 【转载】图论 500题——主要为hdu/poj/zoj

    转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...

  6. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  7. hdu图论题目分类

    =============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...

  8. HDU图论题单

    =============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...

  9. hbase hmaster故障分析及解决方案:Timedout 300000ms waiting for namespace table to be assigned

    最近生产环境hbase集群出现停掉集群之后hmaster无法启动现象,master日志报异常:Timedout 300000ms waiting for namespace table to be a ...

随机推荐

  1. 【剑指offer】 Java实现重建二叉树

    GitHub上的代码链接 /** * @Author: DaleyZou * @Description: 重建二叉树 * 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树. * 假设输入的前序 ...

  2. ABAP术语-Object Type

    Object Type 原文:http://www.cnblogs.com/qiangsheng/archive/2008/03/06/1093159.html Description created ...

  3. JS对象和数组在谷歌浏览器中引用存储的表现

    大家都知道JS的数据分为基本类型和引用类型.具体什么不说了,今天主要说说对象和数组作为引用类型在谷歌浏览器中的表现. 首先,问题是这么发现的.我在控制台使用console打印了一个数组,然后对数组进行 ...

  4. 【php练习源码】

    Something is wrong with the XAMPP installation :-( value[$name]=$sex; } public function getInfomatio ...

  5. Hadoop(17)-MapReduce框架原理-MapReduce流程,Shuffle机制,Partition分区

    MapReduce工作流程 1.准备待处理文件 2.job提交前生成一个处理规划 3.将切片信息job.split,配置信息job.xml和我们自己写的jar包交给yarn 4.yarn根据切片规划计 ...

  6. 批量安装Python第三方库

    1.首先在python程序的文件夹内,新建一个文本文档,名字自定义,在文档中输入需要安装的第三方库,并用英文半角逗号隔开. import os def getTxt(): txt = open(&qu ...

  7. python2.7练习小例子(八)

        8):题目:输出 9*9 乘法口诀表.     程序分析:分行与列考虑,共9行9列,i控制行,j控制列.     程序源代码: #!/usr/bin/python # -*- coding: ...

  8. mysql字符串拼接,存储过程

    添加字段: alter table `user_movement_log`Add column GatewayId int not null default 0 AFTER `Regionid` (在 ...

  9. 7 tftp

    1. TFTP协议介绍 TFTP(Trivial File Transfer Protocol,简单文件传输协议) 是TCP/IP协议族中的一个用来在客户端与服务器之间进行简单文件传输的协议 特点: ...

  10. 洛谷P2307 迷宫

    怎么又是一道叫迷宫的题呀QWQ 题目链接 这道题主要是对并查集的考察,需要注意的坑点在于有可能存在的不止一个联通块. 我们只需要对输入的两个数据进行判断,如果在一个集合中证明有多条路则输出0,如果不在 ...