HDU2137 circumgyrate the string
来源:互联网 发布:夜梦巴黎 知乎 编辑:程序博客网 时间:2024/06/10 04:30
circumgyrate the string
Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4235 Accepted Submission(s): 978
Problem Description
Give you a string, just circumgyrate. The number N means you just circumgyrate the string N times, and each time you circumgyrate the string for 45 degree anticlockwise.
Input
In each case there is string and a integer N. And the length of the string is always odd, so the center of the string will not be changed, and the string is always horizontal at the beginning. The length of the string will not exceed 80, so we can see the complete result on the screen.
Output
For each case, print the circumgrated string.
Sample Input
asdfass 7
Sample Output
a s d f a s s
Author
wangye
Source
HDU 2007-11 Programming Contest_WarmUp
#include <stdio.h>#include <string.h>#define maxn 100char str[maxn];void putBackspace(int n) { while(n--) putchar(' ');}void rotate(int cent, int n) { switch(n) { case 0: puts(str); return; case 1: for(int i = cent << 1, j = cent << 1; i >= 0; --j) { putBackspace(i--); printf("%c\n", str[j]); } return; case 2: for(int j = cent << 1; j >= 0; --j) { putBackspace(cent); printf("%c\n", str[j]); } return; case 3: for(int j = cent << 1, i = 0; j >= 0; --j) { putBackspace(i++); printf("%c\n", str[j]); } return; case 4: for(int j = cent << 1; j >= 0; --j) { printf("%c", str[j]); } putchar('\n'); return; case 5: for(int j = 0, i = cent << 1; i >= 0; ++j) { putBackspace(i--); printf("%c\n", str[j]); } return; case 6: for(int j = 0; j <= cent << 1; ++j) { putBackspace(cent); printf("%c\n", str[j]); } return; case 7: for(int j = 0, i = 0; j <= cent << 1; ++j) { putBackspace(i++); printf("%c\n", str[j]); } return; }}int main() { int n, i, cent; while(scanf("%s%d", str, &n) != EOF) { cent = strlen(str) >> 1; n = (n % 8 + 8) % 8; rotate(cent, n); } return 0;}
0 0
- hdu2137 circumgyrate the string
- HDU2137:circumgyrate the string
- HDU2137 circumgyrate the string
- HDU2137 circumgyrate the string【水题】
- HDU2137 circumgyrate the string 模拟题
- circumgyrate the string
- circumgyrate the string 2137
- HDU 2137 - circumgyrate the string
- HDU 2137 circumgyrate the string
- HDU 2137 circumgyrate the string
- HDU 2137 circumgyrate the string
- hdu 2137 circumgyrate the string
- hdu---2137circumgyrate the string
- hdu 2137 circumgyrate the string
- HDU 2137 circumgyrate the string
- hdu 2137 circumgyrate the string
- hdu 2137 circumgyrate the string
- HDU 2137 circumgyrate the string
- 初识GNU, GCC, CYGWIN, MINGW, MSYS
- shell 正则截取字符串
- touchmove 事件中获取真正触摸点下方的元素
- ruby 格式化字符串 浮点数
- 进程分配内存的两种方式--brk() 和mmap()(不设计共享内存)
- HDU2137 circumgyrate the string
- qt 之QToolButton
- expect学习笔记-1
- 如何全面系统的了解PMP认证及考试?
- 查看oracle版本信息
- 在sql server数据库中快速删除记录,清空表
- 用vs2012时遇到的奇葩问题
- 大型互联网网站架构心得之一:分
- http://www.worldscientific.com/ 查高水平论文和检索的网站