UVA 10905 Children's Game
来源:互联网 发布:山东男人啪的表现知乎 编辑:程序博客网 时间:2024/06/10 13:29
题目链接:点击打开链接
表示最近被高中生虐成渣了,不会正确的思考了。
这道题很有意思,之前就有小朋友问我。给一些正整数,按照一定是序列输出,使组成该数最大。。。表示,自己的思路很凌乱。还是看了别人的思路。
思路很有技巧: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[N]; 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;}
0 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
- 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
- uva 10905 Children's Game
- uva 10905 Children's Game
- HDU 2002 计算球体积
- 用GoogleEarth选择遥感分类的训练样区
- poj_2240 Floyd算法变形套现问题
- Word Ladder
- jquery打开页面
- UVA 10905 Children's Game
- 如何让优秀的程序员更上一层楼
- asp.net,cookie,写cookie,取cookie
- Android开发:在EditText中关闭软键盘
- 【Android笔记】Android MediaPlayer的生命周期
- HDU 2004 成绩转换
- 禁止手机浏览器上两个手指触碰在屏幕上,拉大距离,放大页面;缩小距离,缩小页面
- MyEclipse快捷键的使用
- SVN Working Copy xxx locked