乙_1009 说反话 (20分)

题目:

分析:  倒序输出字符串 

             输入一行getline(cin, s);

stringstream 用法详解

      stream<<t    ;      //向流中传值
      stream>>result;  //向result中写入值

代码:

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <stack>
#include <cmath>
#include <sstream>
using namespace std;
int main(){
 bool flag =true;
   string s;  
      getline(cin, s);
   stringstream ss;
   ss<<s;
   stack<string> sk;
   while(ss>>s){
        sk.push(s);
   }
  
  
   while(!sk.empty()){
    if(flag)   cout << sk.top();
    else   {
     cout << " " ;
     cout << sk.top();
    }
        sk.pop();
       flag=false;
   }
  
 system("pause"); 
 return 0;
}
原文地址:https://www.cnblogs.com/xueshadouhui/p/12943300.html