hd2137
2015-07-22 20:47
218 查看
circumgyrate the string
[b]Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)[/b]
[align=left]Problem Description[/align]
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.
[align=left]Input[/align]
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.
[align=left]Output[/align]
For each case, print the circumgrated string.
[align=left]Sample Input[/align]
asdfass 7
[align=left]Sample Output[/align]
a s d f a s s 题目大意就是一字符串,嗯,长度总为奇数,以中间的字符为轴逆时针旋转,每次旋转45度。 不造有木有可以不用从0到7一个一个写的方法,挺麻烦,嗯,注意n可以为负<pre name="code" class="html">#include<stdio.h> #include<string.h> int main() { int n,i,j,lens; char s[100]; while(~scanf("%s %d",s,&n)) { n=n%8; if(n<0)n+=8; lens=strlen(s); if(n==0)printf("%s\n",s); else if(n==1) { for(i=0;i<lens;++i) { for(j=0;j<lens;++j) { if(j<lens-i-1)printf(" "); else if(j==lens-i-1)printf("%c",s[lens-i-1]); } printf("\n"); } } else if(n==2) { for(i=0;i<lens;++i) { for(j=0;j<lens;++j) { if(j<(lens-1)/2)printf(" "); else if(j==(lens-1)/2)printf("%c",s[lens-1-i]); } printf("\n"); } } else if(n==3) { for(i=0;i<lens;++i) { for(j=0;j<lens;++j) { if(j<i)printf(" "); else if(j==i)printf("%c",s[lens-i-1]); } printf("\n"); } } else if(n==4) { for(i=lens-1;i>=0;i--)printf("%c",s[i]); printf("\n"); } else if(n==5) { for(i=0;i<lens;++i) { for(j=0;j<lens;++j) { if(j<lens-i-1)printf(" "); else if(j==lens-i-1)printf("%c",s[i]); } printf("\n"); } } else if(n==6) { for(i=0;i<lens;++i) { for(j=0;j<lens;++j) { if(j<(lens-1)/2)printf(" "); else if(j==(lens-1)/2)printf("%c",s[i]); } printf("\n"); } } else if(n==7) { for(i=0;i<lens;++i) { for(j=0;j<lens;++j) { if(j<i)printf(" "); else if(j==i)printf("%c",s[i]); } printf("\n"); } } } return 0; }
相关文章推荐
- 利用WIFI(不用数据线)连接Android手机进行调试
- poj 3207 Ikki's Story IV - Panda's Trick 【2-sat 经典建模】
- linux 日志服务器的构建
- 阿里电话面试
- 【iOS】线程安全的文件读写
- wait/notifyAll实现生产者消费者模型仿真
- hdu 5289 Assignment
- java数组--04
- 封装http请求返回统一json格式数据的网络操作
- [翻译] M13ProgressSuite
- 火星人弃疗声明
- xmapp+netbeans调试
- linux文件压缩与解压
- Masonry介绍与使用实践:快速上手Autolayout
- 南阳oj NYoj 寻找最大数(三) 题目1057
- Android底层代码中用到的几种设计模式
- PAT 1001. A+B Format(水题)
- Poj 3177 Redundant Paths (双连通分支+节点统计)
- fragment-实例创建跟使用
- c语言归并排序(poj2299)《学习记录》