一、思路
行、列数的确定:
row = ( N + 2 ) / 3;
column = row + ( N + 2 ) % 3;
二、代码
#include <cstdio>
int main()
{
char c, str[81];
int N = 0, row, column;
while( ( c = getchar() ) != '\n' )
str[N++] = c;
row = ( N + 2 ) / 3;
column = row + ( N + 2 ) % 3;
for( int i = 0; i < row - 1; ++i )
for( int j = 0; j < column; ++j )
if( !j )
printf("%c", str[i]);
else if( j == column - 1 )
printf("%c\n", str[N - 1 - i]);
else printf(" ");
for( int i = 0; i < column; ++i )
printf("%c", str[row + i - 1]);
}