UVa 10905 Children's Game
注意!这不是单纯的字典序排序,比如90、9,应该是990最大
对字符串排序蛋疼了好久,因为别人说string很慢,所以一直没有用过。
看别人用string还是比较方便的,学习一下
对了,这里的cmp函数写的还是很简洁的,比我写的要好得多
#define LOCAL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; bool cmp(const string &a, const string &b)
{
return (a + b > b + a);
} int main(void)
{
#ifdef LOCAL
freopen("10905in.txt", "r", stdin);
#endif int n;
string str[];
while(cin >> n && n)
{
for(int i = ; i < n; ++i)
cin >> str[i];
sort(str, str + n, cmp);
for(int i = ; i < n; ++i)
cout << str[i];
cout << endl;
}
return ;
}
代码君
UVa 10905 Children's Game的更多相关文章
- uva 10905 Children's Game (排序)
题目连接:uva 10905 Children's Game 题目大意:给出n个数字, 找出一个序列,使得连续的数字组成的数值最大. 解题思路:排序,很容易想到将数值大的放在前面,数值小的放在后面.可 ...
- UVA 10905 Children's Game 孩子的游戏 贪心
题意:给出N个数,要求把它们拼凑起来,让得到的数值是最大的. 只要分别比较两个数放前与放后的值的大小,排序后输出就可以了. 比如123和56,就比较12356和56123的大小就行了. 写一个比较函数 ...
- 【字符串排序,技巧!】UVa 10905 - Children’s Game
There are lots of number games for children. These games are pretty easy to play but not so easy to ...
- UVA 10905 Children's Game (贪心)
Children's Game Problem Description There are lots of number games for children. These games are pre ...
- UVa 10905 - Children's Game 排序,题目没有说输入是int 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 10905 - Children's Game(求多个正整数排列后,所得的新的数字的极值)
4thIIUCInter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: st ...
- UVA 10905 Children's Game (贪心)
贪心,假如任意给出一个序列,如果两两交换了以后会变大,那么就交换,直到不能交换为止. #include<bits/stdc++.h> using namespace std; ; stri ...
- Children's Game UVA - 10905
看90,956这样的串,在比较完之前,就确定大小的,必定选大的放在前.而x=98,y=980;这样的,比较x+y和y+x的大小.如果x+y更小,y就放前. #include <iostream& ...
- 10905 - Children's Game
4th IIUC Inter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: ...
随机推荐
- IE6下position解决父元素被撑开的问题
在IE6下面当子元素的宽度/高度大于父元素时, 父元素的宽度/高度就被撑开.IE7以上是不会被撑开的 <style> .f{width:100px; height:100px; backg ...
- 如何修正导入模型的旋转? How do I fix the rotation of an imported model?
原地址:http://game.ceeger.com/Manual/HOWTO-FixZAxisIsUp.html Some 3D art packages export their models s ...
- iOS-CALayer实现简单进度条
/** * 用CALayer定制下载进度条控件 * 1.单独创建出CALayer * 2.直接修改CALayer的frame值,执行隐式动画,实现进度条效果 * 3.用定时器(NSTimer) ...
- 对MySQL DELETE语法的详细解析
以下的文章主要描述的是MySQL DELETE语法的详细解析,首先我们是从单表语法与多表语法的示例开始的,假如你对MySQL DELETE语法的相关内容十分感兴趣的话,你就可以浏览以下的文章对其有个更 ...
- 创建MySQL存储过程示例
创建MySQL存储过程是学习MySQL数据库必须要掌握的知识,下文对创建MySQL存储过程作了详细的介绍,供您参考学习. AD:2013大数据全球技术峰会课程PPT下载 下文将教您如何创建MySQL存 ...
- poj 2425 A Chess Game 博弈论
思路:SG函数应用!! 代码如下: #include<iostream> #include<cstdio> #include<cmath> #include< ...
- arcgis地图操作的资料URL,以供以后查阅
更改Arcgis Web应用程序的端口号8399: http://help.arcgis.com/zh-cn/arcgisserver/10.0/help/arcgis_server_java_hel ...
- Linux基础--用户和组管理
1.账号管理相关文件 1)/etc/passwd 每一行都代表一个账号,有几行就代表有几个账号在你的系统中,不过需要特别留意的是,里头很多账号本来就是系统中必须要的,我们可以简称他为系统账号, ...
- Android ListView无法触发ItemClick事件
Android ListView无法触发ItemClick事件 开发中很常见的一个问题,项目中的listview不仅仅是简单的文字,常常需要自己定义listview,自己的Adapter去继承Base ...
- Crypto++编译使用
简述 Crypto++库是一个用c++ 编写的密码类库,是一个自由软件.有关它的信息可以访问以下两个网站: Crypto++® Library Wiki-Crypto++® Library 简述 下载 ...