题解 | #反序输出#

反序输出

https://www.nowcoder.com/practice/171278d170c64d998ab342b3b40171bb

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

int main() {
    string str1;
    int a, b;
    vector<string> v;
    while (getline(cin, str1)) { // 注意 while 处理多个 case
	  //reverse直接反转源字符串 无返回值
        reverse(str1.begin(),str1.end());
        v.push_back(str1);
    }
    for (int i=0; i < v.size(); i++) {
            cout << v[i] <<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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