HDU 2137 circumgyrate the string
来源:互联网 发布:matlab字符矩阵cell 编辑:程序博客网 时间:2024/06/05 20:54
circumgyrate the string
Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4534 Accepted Submission(s): 1053
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 <iostream>#include <cstring>#include <cstdio>using namespace std;int main(){ char s[85]={}; int n,k; while(scanf("%s%d",s,&n)!=EOF) { int len=strlen(s); k=n%8; if(k<0) k+=8; if(k==2) { for(int i=len-1;i>=0;i--) { printf("%*c\n",(len+1)/2,s[i]); } } else if(k==4) { for(int i=len-1;i>=0;i--) { printf("%c",s[i]); } printf("\n"); } else if(k==6) { for(int i=0;i<len;i++) { printf("%*c\n",(len+1)/2,s[i]); } } else if(k==0) { printf("%s\n",s); } else if(k==1) { for(int i=len-1,j=len;i>=0;i--,j--) { printf("%*c\n",j,s[i]); } } else if(k==3) { for(int i=len-1,j=1;i>=0;i--,j++) { printf("%*c\n",j,s[i]); } } else if(k==5) { for(int i=0;i<len;i++) { printf("%*c\n",len-i,s[i]); } } else if(k==7) { for(int i=0;i<len;i++) { printf("%*c\n",i+1,s[i]); } } } return 0;}
0 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
- 屏幕适配
- 2042 不容易系列之二
- RIME输入法无重码自动上屏
- Android View的绘制流程
- 修改表中的主键
- HDU 2137 circumgyrate the string
- zzulioj 1894: 985的方格难题
- webstorm vuejs 警告“default export is not declared in imported module”
- 从零写一个分布式数据库
- Java 集合系列目录(Category)
- js闭包
- 项目启动报:com.opensymphony.xwork2.config.ConfigurationException: Unable to load configuration.
- 博文转载
- 第4章第1节练习题8 打印指定节点的祖先节点