UVa 490 - Rotating Sentences

来源:互联网 发布:fifaol3韩服数据库 编辑:程序博客网 时间:2024/06/11 21:11

题目:给你一篇文章,将文章旋转顺时针90度输出。

分析:字符串,模拟。找到最大的单词长度,按照列行的顺序输出。

说明:没有字符的地方,用空格填充。

#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;char Satz[110][110];int main(){memset( Satz, 0, sizeof(Satz) );int count = 0;int maxs = 0;while ( gets(Satz[count]) ) {if ( maxs < strlen(Satz[count]) )maxs = strlen(Satz[count]);count ++;}for ( int i = 0 ; i < count ; ++ i )for ( int j = 0 ; j < maxs ; ++ j )if ( !Satz[i][j] )Satz[i][j] = ' '; for ( int i = 0 ; i < maxs ; ++ i ) {for ( int j = count-1 ; j >= 0 ; -- j )printf("%c",Satz[j][i]);printf("\n");}//system("pause");return 0;}


0 0
原创粉丝点击