HDU 2137 circumgyrate the string
2017-10-13 14:19
218 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2137
Time Limit: 10000/1000 MS
(Java/Others) Memory
Limit: 32768/32768 K (Java/Others)
Total Submission(s):
2164 Accepted
Submission(s): 464
[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
[align=left]Author[/align]
wangye
[align=left]Source[/align]
HDU 2007-11 Programming Contest_WarmUp
[align=left]Recommend[/align]
威士忌
题意:给一段字符串和数字N,N表示这段字符串逆时针旋转的次数,每次旋转45°,输出旋转后的字符串。
分析:旋转每8次一循环,并且当N的值取0和4;1和5;2和6;3和7时,输出格式一样,字符串的顺序相反。
代码如下:
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int n,i,flag,j,l;
char w[81];
while(scanf("%s%d",w,&n)!=EOF)
{
l=strlen(w);
if(n%8==0) puts(w);
if(n%8==4||n%8==-4)
{
for(i=0;i<l;i++)
printf("%c",w[l-1-i]);
printf("\n");
}
if(n%8==5||n%8==-3)
{
flag=l-1;
for(i=0;i<l;i++)
{
for(j=0;j<flag;j++)
printf(" ");
printf("%c\n",w[i]);
flag--;
}
}
if(n%8==1||n%8==-7)
{
flag=l-1;
for(i=0;i<l;i++)
{
for(j=0;j<flag;j++)
printf(" ");
printf("%c\n",w[l-1-i]);
flag--;
}
}
if(n%8==6||n%8==-2)
{
flag=l/2;
for(i=0;i<l;i++)
{
for(j=0;j<flag;j++)
printf(" ");
printf("%c\n",w[i]);
}
}
if(n%8==2||n%8==-6)
{
flag=l/2;
for(i=0;i<l;i++)
{
circumgyrate the string
Time Limit: 10000/1000 MS
(Java/Others) Memory
Limit: 32768/32768 K (Java/Others)
Total Submission(s):
2164 Accepted
Submission(s): 464
[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
[align=left]Author[/align]
wangye
[align=left]Source[/align]
HDU 2007-11 Programming Contest_WarmUp
[align=left]Recommend[/align]
威士忌
题意:给一段字符串和数字N,N表示这段字符串逆时针旋转的次数,每次旋转45°,输出旋转后的字符串。
分析:旋转每8次一循环,并且当N的值取0和4;1和5;2和6;3和7时,输出格式一样,字符串的顺序相反。
代码如下:
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int n,i,flag,j,l;
char w[81];
while(scanf("%s%d",w,&n)!=EOF)
{
l=strlen(w);
if(n%8==0) puts(w);
if(n%8==4||n%8==-4)
{
for(i=0;i<l;i++)
printf("%c",w[l-1-i]);
printf("\n");
}
if(n%8==5||n%8==-3)
{
flag=l-1;
for(i=0;i<l;i++)
{
for(j=0;j<flag;j++)
printf(" ");
printf("%c\n",w[i]);
flag--;
}
}
if(n%8==1||n%8==-7)
{
flag=l-1;
for(i=0;i<l;i++)
{
for(j=0;j<flag;j++)
printf(" ");
printf("%c\n",w[l-1-i]);
flag--;
}
}
if(n%8==6||n%8==-2)
{
flag=l/2;
for(i=0;i<l;i++)
{
for(j=0;j<flag;j++)
printf(" ");
printf("%c\n",w[i]);
}
}
if(n%8==2||n%8==-6)
{
flag=l/2;
for(i=0;i<l;i++)
{
相关文章推荐
- HDOJ(HDU) 2137 circumgyrate the string(此题用Java-AC不过!坑)
- hdu 1081 To The Max
- hdu 2137 circumgyrate the string
- Splits the string
- HDU 1405 The Last Practice
- HDOJ(HDU) 2137 circumgyrate the string(此题用Java-AC不过!坑)
- HDU 1405 The Last Practice
- HDU 2137 circumgyrate the string
- hdu 2124 Repair the Wall(贪心算…
- HDU 1202 The calculation of GPA
- HDU 2680 Choose the best route
- HDU 4251 The Famous ICPC Team Ag…
- HDU 2061 Treasure the new start,…
- HDU—— 2137 circumgyrate the string
- HDU 2137 circumgyrate the string
- HDU 1157 Who's in the Middle
- HDU 2137 circumgyrate the string
- hdu 2137 circumgyrate the string
- hdu 2137 circumgyrate the string
- HDU 2137 circumgyrate the string