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: ...
随机推荐
- asp.net 创建文字特效
相信word 中的 艺术字 功能大家都不陌生.今天, 我们就利用C#来制作几款自己的艺术字, 可能会对我们了解字体图像的制作原理有一些帮助. 至于有没有使用价值我保持沉默. 一. 投影效果 程序运行效 ...
- ASP.NET运行机制之一般处理程序(ashx)
一. 概述 新建一个ashx文件 代码如下 <%@ WebHandler Language="C#" Class="TestHandler" %> ...
- javascript设计模式--中介者模式(Mediator)
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- CSLight研究院之学习笔记结合NGUI(一)
原地址:http://www.xuanyusong.com/archives/3088 这两天一直在研究CSLight,目前Unity热更新的方式有两种,一种是ulua这个网上的例子已经很多了.还有一 ...
- HDU1542 Atlantis(矩形面积并)
#pragma warning (disable:4996) #include<iostream> #include<cstring> #include<string&g ...
- 详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI区别
详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI区别 http://blog.sina.com.cn/s/blog_686999de0100jgda.html 实例: ...
- POJ 1552
#include<iostream> using namespace std; int main() { ]; int i,j; ; do{ sum=; ;num[i-]!=&&a ...
- VMware 11 设置U盘启动,总是找不到physicalDrive1
问题:VMware 11 设置U盘启动,总是找不到physicalDrive1 先说一下U盘启动的设置:如图 解决方案: 有两个服务没有进行启动,VMware USB Arbitration Serv ...
- Java集合框架(一)
Java中集合类的关系图: Collection 先来集合中的最大接口——Collection 可以通过查看JDK帮助文档,了解Collection接口中的最共性的方法.通过以下代码示例演示这些方法 ...
- sshpass
示例: ./sshpass -p ‘123456’ ssh -o StrictHostKeyChecking=no root@192.168.1.15 ./sshpass -p ‘123456 ...