UVa 10905 Children's Game 贪心
来源:互联网 发布:s7-300编程手册 编辑:程序博客网 时间:2024/05/16 15:04
/**
* 这是贪心题吧? 或者就说排序吧。。
* 只要保证string数组每个元素连接之后字典序最大就行了。。。
* 其实类比下普通排序的比较数值大小就很好理解了,排序的时候,
* 为了让最后数组从大到小或从小到大,使得每两个需要比较的元素都保持这个性质(在这里就是连接后字典序较大)
* 这STL用的,还能这样啊。。长见识了。。我是看人代码的。。。
*
*/
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int n;
string str[51];
int cmp(const string &a, const string &b) {
return (a + b) > (b + a);
}
int main()
{
int i;
while(cin >> n, n) {
for(i = 0; i < n; i ++)
cin >> str[i];
sort(str, str + n, cmp);
for(i = 0; i < n; i ++)
cout << str[i];
cout << endl;
}
return 0;
}
- UVa 10905 Children's Game 贪心
- UVA 10905 Children's Game(贪心 + 水题)
- UVa 10905 Children's Game / 贪心
- UVa 10905 Children's Game ( 贪心 )
- uva-10905Children's Game(贪心)
- UVA - 10905 Children's Game(贪心)
- UVA 10905 Children's Game (贪心)
- UVA 10905 Children's Game [贪心]
- UVA 10905 Children's Game(贪心)
- UVa 10905 Children's Game (贪心)
- UVA Children’s Game(贪心)
- UVA 10905 Children's Game 孩子的游戏 贪心
- uva - 10905 - Children's Game(贪心,qsort排序)
- uva 10905 - Children's Game(排序中的贪心)
- uva 10905 Children's Game(排序或者有点贪心)
- UVa 10905 - Children's Game
- UVa 10905 - Children's Game
- uva 10905 - Children's Game
- 验证邮箱
- mac开启64位内核
- Flask+Nginx+Gunicorn+Redis+Mysql搭建一个小站
- 安装drupal 7.22时出现的怪现象
- 皮二哥,讲究人
- UVa 10905 Children's Game 贪心
- (原创)自编protel99se鼠标增强工具,支持dxp2004
- innerHTML,outerHTML,innerText,outerText 的区别?
- USTCOJ 1324 Zipper 存储计算结果
- 吐槽 Python Web 框架 Flask
- 如何把图片整合到war3的mpq文件中作为登录背景界面
- zoj 3642 Just Another Information Sharing Problem
- epoll基础
- 自己在VPS上使用 Flask + sqlalchemy + jinja2 + nginx + mysql 架一个小站