circumgyrate the string
来源:互联网 发布:网络平台推广是什么 编辑:程序博客网 时间:2024/06/05 22:51
circumgyrate the string
Time Limit: 10000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3028 Accepted Submission(s): 696
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<stdio.h>#include<string.h>int main(){ char a[88]; int n,i,j,k; while(scanf("%s",a)!=EOF) { k=strlen(a); scanf("%d",&n); n=n%8; if(n<0) n=n+8; switch(n) { case 0: { for(i=0;i<k;i++) printf("%c",a[i]); printf("\n"); break; } case 1: { for(j=k-1;j>=0;j--) { for(i=0;i<j;i++) printf(" "); printf("%c\n",a[j]); } break; } case 2: { for(j=k-1;j>=0;j--) { for(i=0;i<k/2;i++) printf(" "); printf("%c\n",a[j]); } break; } case 3: { for(j=k-1;j>=0;j--) { for(i=k-1;i>j;i--) printf(" "); printf("%c\n",a[j]); } break; } case 4: { for(i=k-1;i>=0;i--) printf("%c",a[i]); printf("\n"); break; } case 5: { for(j=0;j<k;j++) { for(i=k-1;i>j;i--) printf(" "); printf("%c\n",a[j]); } break; } case 6: { for(j=0;j<k;j++) { for(i=0;i<k/2;i++) printf(" "); printf("%c\n",a[j]); } break; } case 7: { for(j=0;j<k;j++) { for(i=0;i<j;i++) printf(" "); printf("%c\n",a[j]); } break; } default :break; } } return 0;}
/*我自己写的,总是错,不知道哪里错了,~~~~(>_<)~~~~ */#include<iostream>#include<iomanip>using namespace std;int main(){char a[88];int n;while(cin>>a){cin>>n;int m=n%8,i,j;if(m<0)m=m+8;int s=strlen(a);switch(m){case 0:{for(i=0;i<s;i++)cout<<a[i];cout<<endl;break; }case 1:{for(i=s-1;i>=0;i--){for(j=0;j<s;j++){if(i==j)cout<<a[i];elsecout<<" ";}cout<<endl;}break; }case 2:{for(i=s-1;i>=0;i--){for(j=0;j<s/2;j++)cout<<" ";cout<<a[i]<<endl;}break;}case 3:{for(i=s-1;i>=0;i--){for(j=s-1;j>=0;j--){if(i==j)cout<<a[i];elsecout<<" ";}cout<<endl;}break; }case 4:{for(i=s-1;i>=0;i--)cout<<a[i];cout<<endl;break;}case 5:{for(i=0;i<s;i++){for(j=s-1;j>=0;j--){if(i==j)cout<<a[i];elsecout<<" ";}cout<<endl;}break; }case 6:{for(i=0;i<s;i++){for(j=0;j<s/2;j++)cout<<" ";cout<<a[i]<<endl;}break; }case 7:{for(i=0;i<s;i++){for(j=0;j<s;j++){if(i==j)cout<<a[i];elsecout<<" ";}cout<<endl;}break;} default :break;}}return 0;}
- hdu2137 circumgyrate the string
- HDU2137:circumgyrate the string
- circumgyrate the string
- circumgyrate the string 2137
- HDU2137 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
- hdu---2137circumgyrate the string
- hdu 2137 circumgyrate the string
- HDU2137 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 模拟题
- java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher
- VC ADO dataGrid 数据库动态绑定
- Discuz7.2密码加密方式
- 飞鸽传书的一个美丽的神话
- Google语音识别学习札记 - Windows PC机上测试语音识别
- circumgyrate the string
- Facebook优化分享后记
- 解决 - java.lang.OutOfMemoryError: unable to create new native thread
- QT 多线程程序设计
- 程序员是不是只在乎自己的一亩三分地
- hero in maze 迷宫
- C语言的那些秘密之---函数返回局部变量
- New Job Start
- ubuntu更新源gpg错误