Problem L: STL——字符串排序

来源:互联网 发布:淘宝音乐 编辑:程序博客网 时间:2024/06/05 02:19
HomeWeb BoardProblemSetStandingStatusStatistics

Problem L: STL——字符串排序

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 3482  Solved: 1666
[Submit][Status][Web Board]

Description

    对N个字符串排序。
    0<N<=50000。每个字符串长度不超过50000,所有字符串长度总和不超过1000000。

Input

    第一行读入N。
    后面N行,每行一个字符串(只包含字母)。

Output

    输出共N行,按字典序从小到大输出。

Sample Input

5bcdefqwertyuiphdjfasdfghjklzzzzz

Sample Output

asdfghjklzzzzbcdefqwertyuiphdjfz

HINT

用STL的string容易解决。


Append Code

[Submit][Status][Web Board]
#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;}

0 0
原创粉丝点击