/*
* UVA_10905.cpp
*
* Created on: 2013年11月4日
* Author: Administrator
*/
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
const int maxn = 55;
bool cmp(const string& a , const string& b){//按照串值递减的顺序设计比较函数
return a+b>b+a;
}
int main(){
int n;
string a[maxn];
// string b = "123";
// string c = "321";
// cout<<b+c<<endl; b+c : 123321
while(scanf("%d",&n)!=EOF,n){
int i;
for(i = 0 ; i < n ; ++i){
cin >> a[i];
}
sort(a,a+n,cmp);
for(i = 0 ; i < n ; ++i){
cout<<a[i];
}
cout<<endl;
}
return 0;
}
(使用STL自带的排序功能进行排序)UVA 10905 Children's Game(求一组数据所能拼出的最大数字串)
最新推荐文章于 2025-08-18 11:23:37 发布
本文提供了一种解决UVA在线评测系统中编号为10905的问题的方法。通过自定义字符串比较函数,实现了字符串值递减排序,并使用C++标准模板库中的sort函数进行排序。该解决方案适用于需要对输入的多个字符串按特定顺序排列的问题。

1098

被折叠的 条评论
为什么被折叠?



