Problem L: STL——字符串排序
Time Limit: 1 Sec
Memory Limit: 128 MB
Submit: 3482
Solved: 1666
Description
对N个字符串排序。
0<N<=50000。每个字符串长度不超过50000,所有字符串长度总和不超过1000000。
Input
第一行读入N。
后面N行,每行一个字符串(只包含字母)。
Output
输出共N行,按字典序从小到大输出。
Sample Input
5bcdefqwertyuiphdjfasdfghjklzzzzz
Sample Output
asdfghjklzzzzbcdefqwertyuiphdjfz
HINT
用STL的string容易解决。
Append Code
한국어< 中文 فارسی English ไทย All Copyright Reserved 2010-2011 SDUSTOJ TEAM
GPL2.0 2003-2011 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
int N;
cin >> N;
vector <string> p;
for(int i = 0; i < N; i++)
{
string t;
cin >> t;
p.push_back(t);
}
sort(p.begin(),p.end());
vector <string> :: iterator ite;
for(ite = p.begin(); ite != p.end(); ite++)
cout << *ite<< endl;
}