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 }
  • 相关阅读:
    DGbroker三种保护模式的切换
    oracle11G使用DGbroker创建dg
    oracle数据泵示例
    oracle DB_LINK
    oracle数据库rman备份计划及恢复
    oracle查看对象信息
    mybatis学习:mybatis的注解开发和编写dao实现类的方式入门
    mybatis学习:mybatis的环境搭建与入门
    mybatis框架学习:
    入门servlet:request请求转发和共享数据
  • 原文地址:https://www.cnblogs.com/invisible/p/2237296.html
Copyright © 2011-2022 走看看