zoukankan      html  css  js  c++  java
  • Q490: Rotating Sentences

    Q490: Rotating Sentences

    在這個問題中你必須將數列文字往順時針方向旋轉90度。也就是說將原本由左到右,由上到下的句子輸出成由上到下,由右到左。

    Input and Output

    輸入最多不會超過100列,每列最多不會超過100個字元。
    合法的字元包括:換行,空白,所有的標點符號,數字,以及大小寫字母。(注意:Tabs並不算是合法字元。)

    最後一列輸入必須垂直輸出在最左邊一行,輸入的第一列必須垂直輸出在最右邊一行。

    請參考sample intput/output。

    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++结束输入是CTL+Z
    #include <iostream>
    #include <string>
    #include <vector>
    using namespace std;
    int main()
    {
        string str;
        vector<string> v;
        string::size_type max_lenght = 0;
        while(getline(cin,str,'\n'))
        {
            if(max_lenght < str.size()) max_lenght = str.size();
            v.push_back(str);
        }
        for (string::size_type index = 0 ; index < max_lenght ; ++index  )
        {
            for(vector<string>::reverse_iterator It = v.rbegin() ;
                It != v.rend() ; ++It)
                {
                    if(index < It->length()) cout<<It->at(index);
                    else cout<<' ';
                }
            endl(cout);
        }
    
        return 0;
    }
  • 相关阅读:
    linux/windows nginx安装
    linux/windows vsftpd安装
    linux 操作命令
    linux/windows java tomcat安装
    常见的Activity Action Intent常量
    Intent.ACTION_PICK
    Android实现抽奖转盘
    Android-短信验证
    Android-多平台分享(新浪微博)
    Android 手势滑动,多点触摸放大缩小图片
  • 原文地址:https://www.cnblogs.com/UnGeek/p/2532802.html
Copyright © 2011-2022 走看看