uva 10905 Children's Game 儿童游戏

题目大意:
给你一堆正整数,让你把这些数连接起来,找出连接后最大的那个…
思路见代码下方(这题挺sb的,别想多了)

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
string s[51];
bool cmp(const string &s1,const string &s2)
{
    if(s1==s2)
    return true;
    string tem1,tem2;
    tem1+=s1,tem1+=s2;
    tem2+=s2,tem2+=s1;
    if(tem1>tem2)
    return true;
    return false;
}
int main()
{
    ios::sync_with_stdio(false);
    int n;
    while(cin>>n,n)
    {
        for(int i=1;i<=n;i++)
        cin>>s[i];
        sort(s+1,s+1+n,cmp);
        for(int i=1;i<=n;i++)
        cout<<s[i];
        cout<<endl;
    }
    return 0;
}

思路:
我真是菜狗啊,上来就寻思怎么摆弄位数使得数最大的排序在前面,当我按照这个思路把代码写出来后血就喷到屏幕上了~~ 还比个j毛啊,两个数a和b,要么a在前面要么b在前面,试一下就知道了~然后我把刚写好的代码删了,然后就过了~~

你可能感兴趣的:(uva 10905 Children's Game 儿童游戏)