UVa Solution 11192 - Group Reverse
#include<stdio.h>
#include<string.h>
int main()
{
int p,i,j,top,G;
char s1[105],s2[105];
scanf("%d",&G);
while(G)
{
scanf("%s",s1);
int len=strlen(s1);
p=len/G;
top=0;
for(i=p-1; i<len; i+=p)
{
for(j=i; j>i-p; j--)
s2[top++]=s1[j];
}
s2[top++]=0;
puts(s2);
scanf("%d",&G);
}
return 0;
}
problem link: http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2133
#include<string.h>
int main()
{
int p,i,j,top,G;
char s1[105],s2[105];
scanf("%d",&G);
while(G)
{
scanf("%s",s1);
int len=strlen(s1);
p=len/G;
top=0;
for(i=p-1; i<len; i+=p)
{
for(j=i; j>i-p; j--)
s2[top++]=s1[j];
}
s2[top++]=0;
puts(s2);
scanf("%d",&G);
}
return 0;
}
problem link: http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=2133
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home