UVA 10905 Children's Game
2014-07-25 16:22
357 查看
题目链接:点击打开链接
表示最近被高中生虐成渣了,不会正确的思考了。
这道题很有意思,之前就有小朋友问我。给一些正整数,按照一定是序列输出,使组成该数最大。。。表示,自己的思路很凌乱。还是看了别人的思路。
思路很有技巧:if(a + b > b + a) than a一定排在b前面。a + b是字符串是相加。。好思路。。弱渣只能继续学习。。!!
Code:
表示最近被高中生虐成渣了,不会正确的思考了。
这道题很有意思,之前就有小朋友问我。给一些正整数,按照一定是序列输出,使组成该数最大。。。表示,自己的思路很凌乱。还是看了别人的思路。
思路很有技巧:if(a + b > b + a) than a一定排在b前面。a + b是字符串是相加。。好思路。。弱渣只能继续学习。。!!
Code:
#include <iostream> #include <algorithm> #include <string> using namespace std; const int N = 55; bool cmp (string a, string b){ return a + b > b + a; } int main(){ int n; while(cin >> n && n){ string str ; for(int i = 0; i < n; i ++){ cin >> str[i]; } sort(str, str + n, cmp); for(int 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 10905 Children's Game ( 贪心 )
- UVA 10905 Children's Game(数字组合求最大)
- UVA - 10905 Children's Game
- UVa 10905 - Children's Game
- 4th IIUC Inter-University Programming Contest, 2005 / 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 孩子的游戏 贪心
- UVA - 10905 - Children's Game (简单排序)
- UVA 10905- Children's Game(sort处理string字符串)
- UVa 10905 Children's Game 解法
- UVA 10905(Children's Game-C的qsort函数和sprintf)
- UVA 10905(p79)----Children's Game