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容易解决。
#include <iostream>
#include <stack>
#include <cstdio>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
using namespace std;
string s[50005];int len[1000005];
int main()
{
int n;
string a;
vector<string> s;
vector<string>::iterator p;
cin>>n;
s.clear();
while(n--)
{
cin>>a;
s.push_back(a);
}
sort(s.begin(),s.end());
for(p=s.begin();p!=s.end();p++)
{
cout<<*p<<endl;
}
return 0;
}