您的位置:首页 > 其它

Rotating Sentences

2015-07-02 21:12 369 查看
Rotating Sentences

In ``Rotating Sentences,'' you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and top to bottom, your program will
display them from top to bottom and right to left.

Input and Output

As input to your program, you will be given a maximum of 100 sentences, each not exceeding 100 characters long. Legal characters include: newline, space, any punctuation characters, digits, and lower case
or upper case English letters. (NOTE: Tabs are not legal characters.)

The output of the program should have the last sentence printed out vertically in the leftmost column; the first sentence of the input would subsequently end up at the rightmost column.

Sample Input

Rene Decartes once said,
"I think, therefore I am."


Sample Output

"R
Ie
n
te
h
iD
ne
kc
,a
r
tt
he
es
r
eo
fn
oc
re
e
s
Ia
i
ad
m,
.
"

#include<iostream>
#include<stdio.h>
#include<string>
#include<cstring>
using namespace std;
const int MN = 101;
char a[MN][MN];
int main()
{
int i=0,m = 0,len[102];
while(gets(a[i]))
{
int t = strlen(a[i]);
len[i]=t;
if(t>m) m = t;
i++;
}
int f = i-1;
for(int j = 0; j != m; j ++){
for(int k = f; k>=0; k--)
if(len[k] > j)
cout<<a[k][j];
else
cout<<" ";
cout<<endl;
}
}

有一点就是把句子末尾缺少的部分添加为空格。[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: