题解 | #字符串排序#
字符串排序
http://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main() {
int n, i;
string word;
cin >> n;
vector<string>vs;
for (i = 0; i < n; i++) {
cin >> word;
vs.push_back(word);
/*
for (int j = i - 1; j >= 0; j--) {
if (vs[j]>vs[j+1]) {
string temp = vs[j];
vs[j] = vs[j + 1];
vs[j + 1] = temp;
}
else {
break;
}
}
*/
}
sort(vs.begin(),vs.end());
for (i = 0; i < n; i++) {
cout << vs[i]<<endl;
}
}