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. 解决问题的思路(如故事版里面有东西,却不见了)(swift里面开发比较多)

    解决问题的思路(如故事版里面有东西,却不见了) 正确效果图: 真机效果图: 内容:不见了 解决步骤:(重点讲解方法1) 1.把背景图隐藏了,如果能出现内容,说明背景图把内容遮住了.那怎么办呢,背景图是 ...

  2. TabbarController进行模块分类和管理

    iOS-CYLTabBarController[好用的TabbarController]   用TabbarController进行模块分类和管理,这里推荐一个CYLTabBarController, ...

  3. js函数只触发一次

    如何让js中的函数只被执行一次?我们有时候会有这种需求,即让一个函数只执行一次,第二次调用不会返回任何有价值的值,也不会报错.下面将通过三个小demo展示使用的方法,当做个人笔记. 1.通过闭包来实现 ...

  4. C/C++使用Socket通信UDP

    接收端 #include <stdio.h> #include <WinSock2.h> #pragma comment(lib,"WS2_32.lib") ...

  5. 【前行】◇第3站◇ 国庆训练营·OI制模拟赛

    [第3站] 国庆训练营·OI制模拟赛Ⅰ 怀着冲刺提高组400的愿望来到这个very small but very interesting 的训练营QwQ 在北大dalao的带领下开始了第一场OI模拟赛 ...

  6. VMware下CentOS7安装后,还原虚拟网络后,敲ifconfig不显示局域网ip解决方法

    VMware下CentOS7安装后,还原虚拟网络后,敲ifconfig不显示局域网ip,没有出现eth0网卡,不能上网,SSH不能连接,输入ifconfig后如下图: 解决方法: 1.编辑网卡的配置文 ...

  7. php开发aes加密总结

    <?php class Aes { /** * aes 加密 解密类库 * @by singwa * Class Aes *说明:本类只适用于加密字符串 * */ private $key = ...

  8. Python面向对象的类的操作

    import randomimport time class ElectronicCoupon(): def __init__(self): self.__ecid=time.strftime('%Y ...

  9. python中 列表常用的操作

    列表可以装大量的数据,不限制数据类型,表示方式:[]:列表中的元素用逗号隔开. lst = [] #定义一个空列表 lst = ["Tanxu",18,"女", ...

  10. DHT11资料

    产品名:温湿度传感器 型号:DHT11 厂商:奥松电子 参数: 相对湿度: 分辨率:0.1%RH        16Bit 精度:25℃  正负 %2 温度: 分辨率:0.1%RH        16 ...