`
xiaoheliushuiya
  • 浏览: 402878 次
文章分类
社区版块
存档分类
最新评论

UVa 490 旋转句子

 
阅读更多

/*

* 解题思路:

* 需要注意、若超过某行长度、需用空格补上

* 利用gets( )按行读取、若读到结尾返回空 !

*/

#include <stdio.h>
#include <string.h>
#define A 110
int main( )
{
    int i;
    int l;
    int maxLen;
    int total;
    char s[ A ][ A ];
    int len[ A ];

    total = 0;
    l = maxLen = 0;
    while( (gets( s[ total ])) !=NULL )
    {
        len[ total ] = strlen( s[ total ]);
        if( len[ total ] > maxLen )
            maxLen = len[total];
        total++;
    }
    l = 0;
    while( l++  < maxLen )
    {
        for( i=total-1;i>=0;i-- )
            if( len[ i ] > l ) printf("%c",s[ i ][ l ] );
            else printf(" ");
        puts("");
    }
    return 0;
}



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics