Problem L: STL——字符串排序

xiaoxiao2021-02-28  119

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]

한국어<  中文 فارسی 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; }
转载请注明原文地址: https://www.6miu.com/read-45202.html

最新回复(0)