1. 程式人生 > >UVa 10905 Children's Game

UVa 10905 Children's Game

字串。。。直接排序(如果用字元陣列儲存不便於排序)

 

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;

bool com(string a,string b)
{
    return(a+b>a+b);
}

int n;

int main()
{
	while((scanf("%d",&n))==1&&n!=0)
	{
		string s[n];
		for(int i = 0;i<n;i++) cin>>s[i];
	    sort(s,s+n,com);
        for(int i=0;i<n-1;i++)
        cout<<s[i];
        cout<<s[n-1]<<endl;
	}
	return 0;
}