5-32 說反話-加強版 (20分)


#include <iostream>
#include <string>
#include <sstream>
#include <stack>
using namespace std;
string str;
stack<string> s;
int main()
{
    while(getline(cin,str))
    {
        istringstream it(str);
        bool isfirst = true;
        while ( it >> str )
        {
            s.push(str);
        }
        while (!s.empty())
        {
            if (isfirst)
            {
                isfirst = false;
                cout<<s.top();
            }
            else
            {
                cout<<" "<<s.top();
            }
            s.pop();
        }
        cout<< endl;
    }

    return 0;
}


發佈了73 篇原創文章 · 獲贊 25 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章