Description
存储一组姓名,如Apple,Tom,Green,Jack 要求按照字典序排序并显示。
Input
输入第一行为样例数m,对于每个样例,第一行为人数n,接下来有n个姓名,n不超过10,每个名字长度不超过20。
Output
对于每个样例输出排序后的结果,每行一个姓名。
Sample Input
14AppleTomGreenJack
Sample Output
AppleGreenJackTom
HINT
Source
#include<bits/stdc++.h>
using namespace std;
int main()
{
int shumu;
cin >> shumu;
while (shumu--)
{
int count;
cin >> count;
string *a = new string[count];
for (int i = 0; i < count; i++)
cin >> a[i];
sort(a, a + count);
for (int i = 0; i < count; i++)
cout << a[i] << endl;
}
system("pause");
}