zoukankan      html  css  js  c++  java
  • 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#23812
    01 char buf[max_size][max_size];
    02 int main()
    03 {
    04     int i;
    05     int len;
    06     int max_len = -1;
    07     memset(buf, 0, sizeof(buf));
    08     for(i = 0; gets(buf[i]); i++)
    09         if((len = strlen(buf[i])) > max_len)
    10             max_len = len;
    11     for(int j = 0; j < max_len; ++j)
    12     {
    13         for(int k = i - 1; k >= 0; --k)
    14             if(buf[k][j])
    15                 fprintf(fout, "%c", buf[k][j]);
    16             else if(j > 0)                     //blank
    17                 fprintf(fout, " ");
    18         fprintf(fout, "\n");
    19     }
    20
    21     return 0;
    22 }
  • 相关阅读:
    怎样练习一万小时
    新闻的未来
    有些人无缘再见,却一生想念
    媒体该如何展示事实之美?
    传统媒体:广告都去哪儿了?
    一线从业者干货分享:不做“忧伤”的媒体人
    整理者与信息平台
    把媒体当手段还是当目的?
    媒体人转身,转身去哪里?
    腾讯新闻的海量服务
  • 原文地址:https://www.cnblogs.com/invisible/p/2237296.html
Copyright © 2011-2022 走看看