题解 | #倒置字符串#

倒置字符串

https://www.nowcoder.com/practice/ee5de2e7c45a46a090c1ced2fdc62355

巧妙的利用了输入以空格隔开的设定,于是字符串数组存一下倒序输出就完事了

#include <iostream>
#include <vector>
using namespace std;

int main() {
    vector<string>s;
    string t;
    while(cin>>t)s.push_back(t);
    for(int i=s.size()-1;i>=0;i--){
        cout<<s[i]<<' ';
    }return 0;
}

全部评论

相关推荐

醉蟀:你不干有的是人干
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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