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 }
  • 相关阅读:
    CF979D Kuro and GCD and XOR and SUM(01Trie)
    2020中国计量大学校赛题解
    CF16E Fish (状压dp)
    2017ccpc杭州站题解
    HDU6274 Master of Sequence(二分+预处理)
    CF899F Letters Removing(树状数组+二分)
    牛客 tokitsukaze and Soldier(优先队列+排序)
    HDU6268 Master of Subgraph(点分治)
    CF862E Mahmoud and Ehab and the function(二分)
    CF1108F MST Unification(生成树+思维)
  • 原文地址:https://www.cnblogs.com/invisible/p/2237296.html
Copyright © 2011-2022 走看看