文章
1
粉丝
52
获赞
0
访问
77
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
vector<string> strs(5); // 创建存储5个字符串的容器
for (int i = 0; i < 5; ++i) {
getline(cin, strs[i]); // 正确读取可能包含空格的字符串
}
sort(strs.begin(), strs.end()); // 默认字典序排序
for (const auto& s : strs) {
cout << s << endl; // 按行输出排序结果
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发