题解 | #反序输出#
反序输出
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")
查看3道真题和解析