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 }
  • 相关阅读:
    [WPF VTK]三维图形开发基础(一)
    WP开发(一)
    [WPF VTK]三维图形开发基础(四)

    WIN8 下IE突然无法打开(管理员权限可打开)
    [WPF VTK]三维图形开发基础(三)
    堆排序、快排的坑
    双向链表之插入
    [WPF VTK]三维图形开发基础(二)
    [转载]Android界面设计学习日志(一)
  • 原文地址:https://www.cnblogs.com/invisible/p/2237296.html
Copyright © 2011-2022 走看看