注意!这不是单纯的字典序排序,比如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的更多相关文章

  1. uva 10905 Children's Game (排序)

    题目连接:uva 10905 Children's Game 题目大意:给出n个数字, 找出一个序列,使得连续的数字组成的数值最大. 解题思路:排序,很容易想到将数值大的放在前面,数值小的放在后面.可 ...

  2. UVA 10905 Children's Game 孩子的游戏 贪心

    题意:给出N个数,要求把它们拼凑起来,让得到的数值是最大的. 只要分别比较两个数放前与放后的值的大小,排序后输出就可以了. 比如123和56,就比较12356和56123的大小就行了. 写一个比较函数 ...

  3. 【字符串排序,技巧!】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 ...

  4. UVA 10905 Children's Game (贪心)

    Children's Game Problem Description There are lots of number games for children. These games are pre ...

  5. UVa 10905 - Children's Game 排序,题目没有说输入是int 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  6. UVa 10905 - Children's Game(求多个正整数排列后,所得的新的数字的极值)

    4thIIUCInter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: st ...

  7. UVA 10905 Children's Game (贪心)

    贪心,假如任意给出一个序列,如果两两交换了以后会变大,那么就交换,直到不能交换为止. #include<bits/stdc++.h> using namespace std; ; stri ...

  8. Children's Game UVA - 10905

    看90,956这样的串,在比较完之前,就确定大小的,必定选大的放在前.而x=98,y=980;这样的,比较x+y和y+x的大小.如果x+y更小,y就放前. #include <iostream& ...

  9. 10905 - Children's Game

    4th IIUC Inter-University Programming Contest, 2005 A Children’s Game Input: standard input Output: ...

随机推荐

  1. JS获取节点方法

    1. 通过顶层document节点获取:(1) document.getElementById(elementId):该方法通过节点的ID,可以准确获得需要的元素,是比较简单快捷的方法.如果页面上含有 ...

  2. php中用于接受表单数据的$_request与$_post、$_get

    一.$_request与$_post.$_get的区别和特点 $_REQUEST[]具用$_POST[] $_GET[]的功能,但是$_REQUEST[]比较慢.通过post和get方法提交的所有数据 ...

  3. close和shutdown的区别

    转的,没验证 close(sock_fd)会把sock_fd的内部计数器减1当sock_fd的内部计数器为0时, 才调用shutodwn(), 并最终释放文件描述符调用shutdown()只是进行了T ...

  4. 13test07;字符排序,去重,三三输出

    #include<iostream> #include<string> using namespace std; void buddle(char*,int);//对输入字符的 ...

  5. poj 3469

    Dual Core CPU Time Limit: 15000MS   Memory Limit: 131072K Total Submissions: 18120   Accepted: 7818 ...

  6. SGU 105

    There is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. ...

  7. SGU 102

    For given integer N (1<=N<=104) find amount of positive numbers not greater than N that coprim ...

  8. 深入浅出ES6(八):Symbols

    作者 Jason Orendorff  github主页  https://github.com/jorendorff 你是否知道ES6中的Symbols是什么,它有什么作用呢?我相信你很可能不知道, ...

  9. MYSQL - ORDER BY & LIMIT

    http://stackoverflow.com/questions/4708708/mysql-order-by-limit

  10. oracle创建表空间,创建用户(转)

    //创建临时表空间 create temporary tablespace test_temp tempfile 'E:\oracle\product\10.2.0\oradata\testserve ...