#include<stdio.h>
#include<string.h>
char ch[105][105];
int main()
{
int cnt = 0, ans = 0;
while( gets(ch[cnt]))
{
int len = strlen( ch[cnt]);
if( len > ans) ans = len;
cnt ++;
}
for(int j = 0; j < ans; j ++)
{
for( int i = cnt - 1; i >= 0; i --) {
if( j < strlen( ch[i]) )
printf( "%c", ch[i][j]);
else
printf( "");
}
printf("\n");
}
return 0;
}
这道题是将输入的句子逆时针转动90°输出,纠结的问题是空格的输出,果断又WA了好几次。
我们需要统计输入了多少句 用cnt计数,最长的句子有多少个字符 用ans计数,然后从最后一个字符开始,
按照一列一列的输出。开始我用的方法是将整个字符串数组全部置为' ',然后输出ch[i][j],但是不知道
怎么不对。之后就换成了判读某句是不是已经输出完,剩下的就用空格补上。