Problem F: STL——字符串排序Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 5060 Solved: 2768
[Submit][Status]Description 对N个字符串排序。
0<N<=50000。每个字符串长度不超过50000,所有字符串长度总和不超过1000000。
Input 第一行读入N。
后面N行,每行一个字符串(只包含字母)。
Output 输出共N行,按字典序从小到大输出。
Sample Input
5
bcdef
qwer
tyuiphdjf
asdfghjklzzzz
z
Sample Output
asdfghjklzzzz
bcdef
qwer
tyuiphdjf
z
HINT用STL的string容易解决。
Append Code
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
int n;
cin>>n;
vector<string> m;
while(n--)
{
string s;
cin>>s;
m.push_back(s);
}
sort(m.begin(),m.end());
for(int i = 0 ; i < m.size() ; i++)
{
cout<<m[i]<<endl;
}
return 0;
}
在这里插入代码片