circumgyrate the string
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
题意,给你一个奇数长度的字符串,转n次,每次转45’转轴为字符串中心,正数逆时针,负数顺时针
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[11111];
int main()
{
int n,i,j;
while(~scanf("%s%d",s,&n))
{
int t,len=strlen(s);
// cout<<t<<endl;
if(n<0)
{
t=(-n)%8;
if(t==1) t=7;
else if(t==2) t=6;
else if(t==3) t=5;
else if(t==5) t=3;
else if(t==6) t=2;
else if(t==7) t=1;
}
else t=n%8;
if(t==0)
{
for(i=0; i<len; i++)
printf("%c",s[i]);
printf("\n");
}
if(t==4)
{
for(i=len-1; i>=0; i--)
printf("%c",s[i]);
printf("\n");
}
if(t==1)
{
int k=len-1;
for(i=len-1; i>=0; i--,k--)
{
for(j=0; j<k; j++)
printf(" ");
printf("%c\n",s[i]);
}
}
if(t==5)
{
int k=len-1;
for(i=0; i<len; i++,k--)
{
for(j=0; j<k; j++)
printf(" ");
printf("%c\n",s[i]);
}
}
if(t==2)
{
for(i=len-1; i>=0; i--)
{
for(j=0;j<len/2;j++)
printf(" ");
printf("%c\n",s[i]);
}
}
if(t==6)
{
for(i=0; i<len; i++)
{
for(j=0;j<len/2;j++)
printf(" ");
printf("%c\n",s[i]);
}
}
if(t==3)
{
int k=0;
for(i=len-1; i>=0; i--,k++)
{
for(j=0; j<k; j++)
printf(" ");
printf("%c\n",s[i]);
}
}
if(t==7)
{
int k=0;
for(i=0; i<len; i++,k++)
{
for(j=0; j<k; j++)
printf(" ");
printf("%c\n",s[i]);
}
}
}
return 0;
}
/*
a
s
d
f
a
s
s
*/