A1031. Hello World for U (20)
#include <stdio.h>
#include <string.h>
int main(){
char str[100];
gets(str);
int len = (int)strlen(str);
// left, right, bottom分别代表左边,右边,底边的字母数
int left, right, bottom;
if((len + 2) % 3 == 0){
left = right = bottom = (len + 2) / 3;
}else{
left = right = (len + 2) / 3;
bottom = left + (len + 2) % 3;
}
int i, j;
for(i = 0; i < left - 1; i++){
printf("%c", str[i]);
for(j = 0; j < bottom - 2; j++)
printf(" ");
printf("%c\n", str[len - i - 1]);
}
for(i = left - 1; i < left - 1 + bottom; i++){
printf("%c", str[i]);
}
return 0;
}