文章
61
粉丝
137
获赞
224
访问
77.7k
 
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    string word = "";
    getline(cin, s);
    stack<string> stk;
    int len = s.size();
    for(int i = 0; i < len; i++){
        if(s[i] != ' ')
            word += s[i];
        else{
            stk.push(word);
            word = "";
        }
    }
    stk.push(word);
    while(!stk.empty()){
        cout << stk.top() << " ";
        stk.pop();
    }
    return 0;
}
登录后发布评论
暂无评论,来抢沙发