mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-27 08:26:20 +00:00
34 lines
666 B
C
34 lines
666 B
C
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
int k;
|
||
|
char s[105];
|
||
|
|
||
|
int main() {
|
||
|
scanf("%d\n%s", &k, s);
|
||
|
|
||
|
int len = strlen(s);
|
||
|
|
||
|
for (int i = 0, cnt = 0; i < len; i += k, cnt++) {
|
||
|
if (i + k - 1 < len) {
|
||
|
if (cnt % 2 == 1) {
|
||
|
for (int j = i + k - 1; j >= i; j--) {
|
||
|
printf("%c", s[j]);
|
||
|
}
|
||
|
} else {
|
||
|
for (int j = i; j < i + k; j++) {
|
||
|
printf("%c", s[j]);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
for (int j = i; j < len; j++) {
|
||
|
printf("%c", s[j]);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
printf("\n");
|
||
|
|
||
|
return 0;
|
||
|
}
|