zoukankan      html  css  js  c++  java
  • 浙江大学PAT上机题解析之1009. 说反话 (20)

    1009. 说反话 (20)

    时间限制 
    400 ms
    内存限制 
    32000 kB
    代码长度限制 
    8000 B
    判题程序   
    Standard
    作者   
    CHEN, Yue

    给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。

    输入格式:测试输入包含一个测试用例,在一行内给出总长度不超过80的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用1个空格分开,输入保证句子末尾没有多余的空格。

    输出格式:每个测试用例的输出占一行,输出倒序后的句子。

    输入样例:
    Hello World Here I Come
    
    输出样例:
    Come I Here World Hello
    


     

     
    #include<iostream>
    #include <stack>
    #include <string>
    using namespace std;
    
    
    int main()
    {
      bool  flag=false;
    
      stack<string>  s;
      string   str;
      while(cin>>str)
         s.push(str);
      while(!s.empty())
      {
        if (flag)
          cout<<" ";
        else
          flag=true;
    
        cout<<s.top();
        s.pop();
      }
    
      //system("pause");
      return 0;
    }

  • 相关阅读:
    JS实现类似网页的测试考卷
    Following Orders(poj1270)
    1007
    Intervals(poj1201)
    LightOJ
    1002
    King's Order(hdu5642)
    Beautiful Walls
    A. Watchmen(Codeforces 650A)
    Shortest Path(hdu5636)
  • 原文地址:https://www.cnblogs.com/ainima/p/6331287.html
Copyright © 2011-2022 走看看