• 乙_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;
    }
  • 相关阅读:
    java final计算
    浅析Java中的final关键字
    easyui
    Java:类与继承
    java中&和&&
    XML
    JSON
    SQL
    selenium
    Metasploit
  • 原文地址:https://www.cnblogs.com/xueshadouhui/p/12943300.html
Copyright © 2020-2023  润新知