題目描述
給定n個字符串,請對n個字符串按照字典序排列。
輸入描述:
輸入第一行爲一個正整數n(1≤n≤1000),下面n行爲n個字符串(字符串長度≤100),字符串中只含有大小寫字母。
輸出描述:
數據輸出n行,輸出結果爲按照字典序排列的字符串。
示例1
輸入
9
cap
to
cat
card
two
too
up
boat
boot
輸出
boat
boot
cap
card
cat
to
too
two
up
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
using namespace std;
int main(){
int n;
string s1;
multiset<string> s2;
cin>>n;
while(n){
cin>>s1;
s2.insert(s1);
n--;
}
multiset<string>::iterator a=s2.begin();
multiset<string>::iterator b=s2.end();
for(;a!=b;a++){
cout<<*a<<endl;
}
return 0;
}