HDU 2135 Rolling table
http://acm.hdu.edu.cn/showproblem.php?pid=2135
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.
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.
#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的更多相关文章
- HDOJ(HDU) 2135 Rolling table
Problem Description After the 32nd ACM/ICPC regional contest, Wiskey is beginning to prepare for CET ...
- 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 ...
- 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). 根 ...
- POJ 2135 Farm Tour && HDU 2686 Matrix && HDU 3376 Matrix Again 费用流求来回最短路
累了就要写题解,近期总是被虐到没脾气. 来回最短路问题貌似也能够用DP来搞.只是拿费用流还是非常方便的. 能够转化成求满流为2 的最小花费.一般做法为拆点,对于 i 拆为2*i 和 2*i+1.然后连 ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
- 转载:hdu 题目分类 (侵删)
转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...
- hdu图论题目分类
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...
- HDU图论题单
=============================以下是最小生成树+并查集====================================== [HDU] 1213 How Many ...
- hbase hmaster故障分析及解决方案:Timedout 300000ms waiting for namespace table to be assigned
最近生产环境hbase集群出现停掉集群之后hmaster无法启动现象,master日志报异常:Timedout 300000ms waiting for namespace table to be a ...
随机推荐
- BZOJ1607: [Usaco2008 Dec]Patting Heads 轻拍牛头(模拟 调和级数)
Time Limit: 3 Sec Memory Limit: 64 MBSubmit: 3031 Solved: 1596[Submit][Status][Discuss] Descriptio ...
- Linux计算某一列的和
ll | awk '{print $5}' | egrep -v "^$"| paste -sd+|bc 简单说明: ll:拿到当前目录下所有的文件大小 awk:拿到第几列 egr ...
- 在mac上显示网速的软件——iStat Menus 5:
在mac上显示网速的软件——iStat Menus 5: https://bjango.com/mac/istatmenus/ 注册码: Email: 982092332@qq.com SN: GAW ...
- 【poe设备加电配置】
开启接口的poe功能: [interface_name]: 配置poe端口的最大功率: [interface_name[: 配置poe的端口工作模式: [interface_name[: 配置poe端 ...
- MySQL索引介绍
引言 今天Qi号与大家分享什么是索引.其实索引:索引就相当于书的目录 索引介绍 用官方的话说就是 索引是为了加速对表中数据行的检索而创建的一种分散的存储结构.索引是针对表而建立的,它是由数据页面以外的 ...
- Redis面试问题
下面列出的这些其中有一些是我面试时遇到的,但是当时自己还不会,所以在网站上找了以下,然后整理出来,加强记忆 感谢码洞将这些问题整理出来: Redis有哪些数据结构? 字符串String.字典Hash. ...
- C语言常用关键语法精华总结
1.关于typedef的用法总结 2.typedef struct的用法 3.typedef函数指针用法 4.数组指针(数组类型的指针)与指针数组 5.真正明白c语言二级指针 6.C语言for循环(及 ...
- 为什么我要放弃javaScript数据结构与算法(第三章)—— 栈
有两种结构类似于数组,但在添加和删除元素时更加可控,它们就是栈和队列. 第三章 栈 栈数据结构 栈是一种遵循后进先出(LIFO)原则的有序集合.新添加的或待删除的元素都保存在栈的同一端,称为栈顶,另一 ...
- xss挑战赛小记 0x02(prompt(1))
0x0O 上次搜xss挑战赛的时候 还找到了一个看上去难度更高的挑战赛 今天做了一下 学到了很多新东西 这个挑战赛能够在页面成功prompt(1)就算过关了 挑战地址 http://prompt.ml ...
- jetbraints激活码
G91XMO9AVI-eyJsaWNlbnNlSWQiOiJHOTFYTU85QVZJIiwibGljZW5zZWVOYW1lIjoic29uZyB3YW5nIiwiYXNzaWduZWVOYW1lI ...