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. 极光推送小结 - iOS

    此次即友盟分享小结(友盟分享小结 - iOS)之后对推送也进行了一版优化.此次分享内容依然基于已经成功集成 SDK 后 code 层级部分. 注:此次分享基于 SDK 3.1.0,若版本相差较大,仅供 ...

  2. mysql存储过程和函数(一)

    存储过程和函数是事先经过编译并存储在数据库的一段sql语句集合,调用存储过程和函数可以简化应用程序开发人员的很多工作,减少数据在数据库和应用服务器之间的传输,对提高数据运行效率是有好处的. 存储过程和 ...

  3. 技能get:用HTML5实现波浪效果

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  4. [SCOI2009]windy数(数位DP)

    题目描述 windy定义了一种windy数.不含前导零且相邻两个数字之差至少为2的正整数被称为windy数. windy想知道, 在A和B之间,包括A和B,总共有多少个windy数? 输入输出格式 输 ...

  5. linux系统之-vi编辑器

    在linux系统使用中,掌握熟练的vi编辑器,可以提高linux工作效率.那么vi编辑器的使用方法有哪些呢? vi编辑器可在绝大部分linux发行版中使用. Vi编辑器的作用:创建或修改文件:维护li ...

  6. spring的事务处理

    说到事务,无非就是事务的提交commit和回滚rollback. 事务是一个操作序列,这些操作要么全部都执行成功,事务去提交,要么就是有一个操作失败,事务去回滚. 要知道事务的4大特性ACID.即原子 ...

  7. 程序设计的SOLID原则

    要想设计一个良好的程序,建议采用SOLID原则,若考虑了SOLID,可以使程序在模块内具有高内聚.而模块间具有低耦合的特点. SOLID原则包括5方面的内容: S---单责任原则(SRP) 一个模块只 ...

  8. 网站apache环境S2-057漏洞 利用POC 远程执行命令漏洞复现

    S2-057漏洞,于2018年8月22日被曝出,该Struts2 057漏洞存在远程执行系统的命令,尤其使用linux系统,apache环境,影响范围较大,危害性较高,如果被攻击者利用直接提权到服务器 ...

  9. Linux编程之Epoll高并发

    网络上所有资料都说epoll是高并发.单线程.IO重叠服用的首选架构,比select和poll性能都要好,特别是在有大量不活跃连接的情况下.具体原理就不阐述了,下面说说使用. 具有有三个函数: #in ...

  10. go学习笔记-类型转换(Type Conversion)

    类型转换(Type Conversion) 类型转换用于将一种数据类型的变量转换为另外一种类型的变,基本格式 type_name(expression) type_name 为类型,expressio ...