HJ14题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int num = 0;
string str;
vector<string> vec;
cin >> num;
while (num--) {
// getline(cin, str);
cin >> str;
vec.push_back(str);
}
sort(vec.begin(), vec.end()); // 使用sort进行字典序排列
for (auto it = vec.begin(); it != vec.end(); it++) {
cout << *it << endl;
}
}
// 64 位输出请用 printf("%lld")
文远知行公司福利 482人发布
