11192 - Group Reverse
Problem Link:Click Here!
Solution:
#include<stdio.h>
#include<string.h>
int main(void){
int a,l,i,j,m,n;
char str[101],temp;
while(scanf("%d",&a)==1 && a!=0){
scanf(" %s",str);
l=strlen(str);
n=l/a;
for(i=0;i<=l-n;i=i+n){
m=i;
j = (m+n)-1;
while (m < j) {
temp = str[m];
str[m] = str[j];
str[j] = temp;
m++;
j--;
}
}
printf("%s\n",str);
}
return 0;
}
No comments:
Post a Comment