题解 | #字符串排序#
字符串排序
http://www.nowcoder.com/practice/dfeed0e0e4624814b122265e859783b2
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
int n;
string str;
while(cin >> n){
getchar();
vector<string> vec;
while(n--){
getline(cin,str);
if(str == "stop")
break;
vec.push_back(str);
}
sort(vec.begin(),vec.end(),[](const string a,const string b){
return a.length() < b.length();
});
for(auto it : vec)
cout << it << endl;
}
}