Skip to content

Instantly share code, notes, and snippets.

@amoshyc
Created December 1, 2014 09:55
Show Gist options
  • Save amoshyc/3a84fcb873bc849d3a5b to your computer and use it in GitHub Desktop.
Save amoshyc/3a84fcb873bc849d3a5b to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int g;
while (scanf("%d", &g)) {
if (g == 0) break;
char input[110];
scanf("%s", input);
int len = strlen(input);
int width = len / g;
int i;
for(i=0; i<len; i+=width) {
int j;
for(j=0; j<width/2; j++) {
/* swap input[i+j], input[i+width-1-j]*/
char temp = input[i+j];
input[i+j] = input[i+width-1-j];
input[i+width-1-j] = temp;
}
}
printf("%s\n", input);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment