您的位置:首页 > 其它

uva 10905-Children’s Game

2013-06-05 22:12 190 查看
字符串比较

#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>

using namespace std;

bool cmp(const string& str1,const string& str2)
{
return (str1+str2)>(str2+str1);
}
int N,num;
vector<string> str;
char s[100];
void input()
{
for(int i=0; i<N; i++)
{
scanf("%s", s);
str.push_back(string(s));//memcpy(str[num++], s, strlen(s)+1);
}
}
int main()
{
while(scanf("%d",&N)==1)
{
if(N==0) break;
str.clear();
input();
sort(str.begin(), str.end(), cmp);//solve();
for(int i=0; i<str.size(); i++)
printf("%s",str[i].c_str());
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: