HDU 2137 circumgyrate the string
来源:互联网 发布:小米4支持什么网络制式 编辑:程序博客网 时间:2024/06/05 15:46
circumgyrate the string
Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2583 Accepted Submission(s): 562
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
题意:就是旋转字符串。周期是8。注意正负。
AC代码:
#include <cstdio>#include <cstring>int main(){ char str[80]; int n; while(scanf("%s%d",str,&n)!=EOF) { int len=strlen(str); for(int i=0;i<len;i++) { if(n%8==0) { putchar(str[i]); if(i==len-1) putchar('\n'); } else if(n%8==1||n%8==-7) { for(int j=0;j<len-1-i;j++) putchar(' '); printf("%c\n",str[len-1-i]); } else if(n%8==2||n%8==-6) { for(int j=0;j<len/2;j++) putchar(' '); printf("%c\n",str[len-1-i]); } else if(n%8==3||n%8==-5) { for(int j=0;j<i;j++) putchar(' '); printf("%c\n",str[len-1-i]); } else if(n%8==4||n%8==-4) { putchar(str[len-1-i]); if(i==len-1) putchar('\n'); } else if(n%8==5||n%8==-3) { for(int j=0;j<len-1-i;j++) putchar(' '); printf("%c\n",str[i]); } else if(n%8==6||n%8==-2) { for(int j=0;j<len/2;j++) putchar(' '); printf("%c\n",str[i]); } else if(n%8==7||n%8==-1) { for(int j=0;j<i;j++) putchar(' '); printf("%c\n",str[i]); } } } return 0;}
- 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
- HDU—— 2137 circumgyrate the string
- circumgyrate the string 2137
- HDU 2137 circumgyrate the string
- hdu2137 circumgyrate the string
- HDU2137:circumgyrate the string
- circumgyrate the string
- HDU2137 circumgyrate the string
- 源码分享(二)
- 中断共享
- PHP 页面编码声明方法详解(header或meta)
- Drag Drop行为探秘
- 与数据库有关的统计计算
- HDU 2137 circumgyrate the string
- php内部字符串编码转换函数mb_convert_encoding使用方法介绍
- 包管理系统分析
- HTML5学习(1) 模块拖动
- 调试Release发布版程序的Crash错误
- 定义宏时千万不要把宏的“参数名”和宏中用到的结构体成员名相同!
- Android从驱动层到应用程序层的通信
- 全球地名中英文对照表(A)
- 细说 Form (表单)