题解 | #句子逆序#

句子逆序

https://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3

#include <cstdlib>
#include <iostream>
#include<sstream>
#include <stack>
using namespace std;

int main() {
    string s;
    getline(cin,s);
    string word;
    stack<string> stk;
    istringstream iss(s);
    while(getline(iss,word,' '))stk.push(word);
    while(stk.size() != 1){
        cout << stk.top() << ' ';
        stk.pop();
    }
    cout << stk.top()<<endl;
    stk.pop();
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

码农索隆:想看offer细节
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 13:38
8月实习会变多吗现在还没找到实习该怎么办...回复的hr好少
码农索隆:3-4月就要开始找,基本上6月份就发offer,7月初已经开始暑期实习了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务