Problem F: STL——字符串排序

Problem F: STL——字符串排序
Time Limit:  1 Sec   Memory Limit:  128 MB
Submit:  3886   Solved:  1942
[ Submit ][ Status ][ Web Board ]
Description
    对N个字符串排序。
    0
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
#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
int N,n;
vectorst;
string s;
cin>>N;
for(n=0;n
{
cin>>s;
st.push_back(s);
}
stable_sort(st.begin(),st.end());
//对给定区间所有元素进行稳定排序
vector::iterator it;
for(it=st.begin();it
{
cout<<*it;
cout<
}

return 0;
}


你可能感兴趣的:(C++)