circumgyrate the string 2137
来源:互联网 发布:上海交大网络空间安全 编辑:程序博客网 时间:2024/05/18 21:41
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
#include <iostream>#include <cstring>#include <string>#include <cstdio>int main(int argc, const char* argv[]){ std::string sz; int n; while (std::cin >> sz) { //if(!(std::cin >> n)) break; ///可能cin对类型检查比较严格、有数据没有被处理 if (scanf("%d", &n) == EOF) break; if (n<0) { n = -n; n = 8-n%8; } int l = strlen(sz.c_str()); if (n % 8 == 0) { std::cout << sz << std::endl; } else if (n % 8 == 1) { int m = l - 1; for (int i=l-1; i>=0; --i) { for (int j=0; j<m; ++j) { std::cout << " "; } std::cout << sz[i] << std::endl; --m; } } else if (n % 8 == 2) { int m = l/2; for (int i=l-1; i>=0; --i) { for (int j=0; j<m; ++j) { std::cout << " "; } std::cout << sz[i] << std::endl; } } else if (n % 8 == 3) { int m = 0; for (int i=l-1; i>=0; --i) { for (int j=0; j<m; ++j) { std::cout << " "; } std::cout << sz[i] << std::endl; ++m; } } else if (n % 8 == 4) { for (int i=l-1; i>=0; --i) { std::cout << sz[i]; } std::cout << std::endl; } else if (n % 8 == 5) { int m = l - 1; for (int i=0; i<l; ++i) { for (int j=0; j<m; ++j) { std::cout << " "; } std::cout << sz[i] << std::endl; --m; } } else if (n % 8 == 6) { int m = l/2; for (int i=0; i<l; ++i) { for (int j=0; j<m; ++j) { std::cout << " "; } std::cout << sz[i] << std::endl; } } else { int m = 0; for (int i=0; i<l; ++i) { for (int j=0; j<m; ++j) { std::cout << " "; } std::cout << sz[i] << std::endl; ++m; } } } return 0;}
0 0
- 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
- HDU—— 2137 circumgyrate the string
- hdu2137 circumgyrate the string
- HDU2137:circumgyrate the string
- circumgyrate the string
- HDU2137 circumgyrate the string
- HDU2137 circumgyrate the string【水题】
- NYOJ-111-分数加减法
- 2009年9月11日周记
- 好不容易大白天
- iOS开发何如在调试的时候轻松找到程序在哪里崩溃
- 那些困扰我的计算机术语
- circumgyrate the string 2137
- android编译环境搭建后ubuntu12.04黑屏不能进系统( libgl1-mesa-glx:i386)
- 使用MySQL全文索引
- Eclipse将引用了第三方jar包的Java项目打包成jar文件的两种方法
- 大数据究竟是什么?
- Linux驱动程序的模块参数
- asp.net获取当前时间
- apache kafka系列之-监控指标
- android CMWAP, CMNET有何区别