Hduoj2137【水题】
来源:互联网 发布:写真机蒙泰软件 编辑:程序博客网 时间:2024/05/29 04:16
/*circumgyrate the string Time Limit : 10000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 2 Accepted Submission(s) : 1Font: Times New Roman | Verdana | Georgia Font Size: ← →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 Inputasdfass 7Sample Outputa s d f a s sAuthorwangye SourceHDU 2007-11 Programming Contest_WarmUp */#include<stdio.h>#include<string.h>int main(){char s[84];int i, j, k, n, l;while(scanf("%s %d", s, &n) != EOF){n %= 8;if(n < 0){n += 8;}l = strlen(s);if(n == 1){for(i = 0; i < l; ++i){for(j = 0; j < l-1-i; ++j)printf(" ");printf("%c\n", s[l-1-i]);}}else if(n == 2){for(i = 0; i < l; ++i){for(j = 0; j < l/2; ++ j)printf(" ");printf("%c\n",s[l-1-i]);}}else if(n == 3){for(i = 0; i < l; ++i){for(j = 0; j < i; ++j)printf(" ");printf("%c\n", s[l-1-i]);}}else if(n == 4){for(i = 0; i < l; ++i)printf("%c", s[l-1-i]);printf("\n");}else if(n == 5){for(i = 0; i < l; ++i){for(j = 0; j < l-1-i; ++j)printf(" ");printf("%c\n", s[i]);}}else if(n == 6){for(i = 0; i < l; ++i){for(j = 0; j < l/2; ++j)printf(" ");printf("%c\n",s[i]);}}else if(n == 7){for(i = 0; i < l; ++i){for(j = 0; j < i; ++j)printf(" ");printf("%c\n", s[i]);}}else{printf("%s\n",s);}}return 0;}
题意:给定一个字符串,长度为奇数,并给出一个n,以字符串中心为旋转原点旋转,每次旋转45°,输出n次旋转后的字符串。
注意:
1.N可以是负数2.当横向输出时,不用输出上下的N个空格和换行,当竖直输出的时候,应该输出N行左边的空格3.所有输出字符的后面没有空格
0 0
- Hduoj2137【水题】
- 水题
- 水题
- 水题
- 水题
- 【水题】
- 水题
- 水题:
- 水题
- 水题~
- 水题
- 水题
- 水题
- 水题
- 水题
- 水题
- 【水题】
- 水题
- UnitTestpp 笔记
- Android_控制闪光灯
- jquery简述
- 哈夫曼树与哈夫曼编码(C语言代码实现)
- cocos2dx学习笔记:自定义工程路径及cocoswidget配置
- Hduoj2137【水题】
- three.js 源码注释(七十)extras/geometries/CubeGeometry.js
- 机器学习基础(四)LMS,代价函数的求解和概率意义
- C++定义不知道大小的二维动态数组
- Oracle instr函数
- jquery常用技巧及常用方法列表
- iOS 8代码怪谈
- 1077.Kuchiguse
- 关于与运算和取余之间的关系