fzuProblem 2088 最长队名
http://acm.fzu.edu.cn/problem.php?pid=2088
一个简单的字符串排序然后输出;然而对于我们这种对c++熟悉又想用sort来偷懒的人来说;这题就是一脸懵逼;定义二维字符数组,用%s输入;最后去sort排序;然后直接膨出sort排序出现错误;后来才知道;c里面的字符数组的字符串是不能用来sort排序的;要用c++里面 的string串;因为这里面有重载运算;这个我也不懂;反正就是只能拥有string串才能用sort对字符串排序;
#include<stdio.h>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std ;
int main()
{
int t,n, i;
string s[10005];
scanf("%d",&t);
while(t--){
scanf("%d",&n);
for(i = 0; i < n; i++)
{
cin>>s[i];
}
sort(s,s+n);//sort对字符串排序只能是c++中string类型
for(i = 0; i < n; i++)
cout<<s[i];
printf("\n");
}
return 0;
}