Sample Input
helloworld!
Sample Output
h !
e d
l l
lowor
思路: 模拟就好。
代码:
#include <stdio.h>
#include <string.h>
char a[101];
int main()
{
gets(a);
int k = (strlen(a) + 2) / 3;
int t = strlen(a) - 2 * k + 2;
for (int i = 0; i < k - 1; ++i)
{
printf("%c", a[i]);
for (int j = 0; j < t - 2; ++j)
printf(" ");
printf("%c", a[strlen(a) - 1 - i]);
printf("\n");
}
for (int i = 0; i < t; ++i)
printf("%c", a[k + i - 1]);
//getchar();getchar();
return 0;
}
来源:CSDN
作者:ssqsssq
链接:https://blog.csdn.net/weixin_43778744/article/details/103575330