HDU2135 Rolling table【水题】
来源:互联网 发布:动漫周边网店淘宝 编辑:程序博客网 时间:2024/06/02 04:56
Rolling table
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2024 Accepted Submission(s): 977
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
Author
Wiskey
Source
HDU 2007-11 Programming Contest_WarmUp
题目大意:给你一个N*N的字符矩阵,再给一个翻转次数M,翻转一次为90°,M为正
表示顺时针翻转,M为负表示逆时针旋转。
思路:将M对4取余,总共分四种情况,根据翻转情况输出相应结果。
#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>using namespace std;char s[12][12];int main(){ int M,N; while(cin >> N >> M) { getchar(); memset(s,0,sizeof(s)); for(int i = 0; i < N; ++i) cin >> s[i]; if(M%4==1 || M%4==-3) { for(int j = 0; j < N; ++j) { for(int i = N-1; i >= 0; --i) cout << s[i][j]; cout << endl; } } else if(M%4 == 2 || M%4==-2) { for(int i = N-1; i >= 0; --i) { for(int j = N-1; j >= 0; --j) cout << s[i][j]; cout << endl; } } else if(M%4 == 3 || M%4==-1) { for(int j = N-1; j >= 0; --j) { for(int i = 0; i < N; ++i) cout << s[i][j]; cout << endl; } } else { for(int i = 0; i < N; ++i) { for(int j = 0; j < N; ++j) cout << s[i][j]; cout << endl; } } } return 0;}
0 0
- HDU2135 Rolling table【水题】
- HDU2135 Rolling table 模拟题
- 【HDU 2135】【水题】 Rolling table
- HDU 2135 Rolling table
- hdu 2135 Rolling table
- HDU 2135 ----Rolling table
- Rolling table 2135
- hdu 2135 Rolling table
- HDOJ 2135 Rolling table
- JAVA hdu 2135 Rolling table
- 杭电2135Rolling table
- HDOJ(HDU) 2135 Rolling table
- 杭电acm—2135 Rolling table
- HDU 2135 Rolling table
- HDU 2135 Rolling table(方阵旋转+找规律)
- rolling hash
- Rolling Variance
- Rolling Patch
- 这几天好累谢了好多代码
- 自制操作系统 第1步
- 05-1. 约分最简分式(15)
- 声明和定义
- iOS 开发之UIButton的使用
- HDU2135 Rolling table【水题】
- 小小的翻译,嘿嘿,翻译的不咋地
- Wiki - Chrome网页翻译无法使用的解决办法
- hi3518c + live555 实时传输 客户端显示的时候延时问题初步解决
- linux进程管理命令
- poj plan
- SVN合作开发经常用到功能
- 05-2. 念数字(15)
- POJ 3169 Layout (差分约束系统 + Bellman-ford算法)