490 – Rotating Sentences

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,
.
"


C++语言: Codee#2381201charbuf[max_size][max_size];

02intmain()

03{

04inti;

05intlen;

06intmax_len=-1;

07memset(buf,0,sizeof(buf));

08for(i=0;gets(buf[i]);i++)

09if((len=strlen(buf[i]))>max_len)

10max_len=len;

11for(intj=0;j<max_len;++j)

12{

13for(intk=i-1;k>=0;--k)

14if(buf[k][j])

15fprintf(fout,"%c",buf[k][j]);

16elseif(j>0)//blank

17fprintf(fout," ");

18fprintf(fout,"\n");

19}

20

21return0;

22}原文链接: https://www.cnblogs.com/invisible/archive/2011/11/05/2237296.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/35805

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月8日 下午12:38
下一篇 2023年2月8日 下午12:39

相关推荐