#include<string> #include <iostream> #include<vector> #include<algorithm> using namespace std; vector<string> v; int main() { int n; cin >> n; while(n--) { string tmp; cin >> tmp; v.push_back(tmp); } sort(v.begin(), v.end()); for (auto it = v.begin(); it != v.end(); it++) { cout << *it << endl; } }
sort函数默认对字符串就是按字典序排序