Created
December 1, 2014 09:55
-
-
Save amoshyc/3a84fcb873bc849d3a5b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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