文章
34
粉丝
18
获赞
6
访问
14.5k
#include <iostream>
#include <stack>
using namespace std;
int main(){
stack<string> ss;
string s;
getline(cin,s);
for(int i = 0;i < s.size();i ++){
string word = "";
int j = i;
// 将单词入栈
while(j < s.size() && s[j] != ' '){
word = word + s[j];
j ++;
}
ss.push(word);
i = j;
}
while(ss.size()){
string str = ss.top();
cout << str << ' ';
ss.pop();
}
cout << endl;
return 0;
}
登录后发布评论
暂无评论,来抢沙发