/*
推荐题型:三星
特殊排序,其实就是贪心吧
题意:输入N个整数,由这些整数组成一个大整数,求组成所有大整数中最大值
思路:首先从局部考虑两个整数如果满足a+b>=b+a,则a需要排在b之前,这就是排序的判断条件。只需要在cmp中定义即可。
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
const int nMax=57,mMax=500;
char str[nMax][mMax];
int cmp(const void *a,const void *b)
{
char *pa=(char *)a;
char *pb=(char *)b;
char s1[mMax*2],s2[mMax*2];
strcpy(s1,pa);
strcpy(s1+strlen(pa),pb);
strcpy(s2,pb);
strcpy(s2+strlen(pb),pa);
return strcmp(s2,s1);
}
int main()
{
//freopen("f://data.in","r",stdin);
int N;
while(scanf("%d",&N) && N)
{
for(int i=0;i<N;i++)
scanf("%s",str[i]);
qsort(str,N,sizeof(str[0]),cmp);
for(int i=0;i<N;i++)
printf("%s",str[i]);
printf("\n");
}
return 0;
}
分享到:
相关推荐
《恋与肥宅喵》 Made For the 48 hours Game Jam hold by Perfect World(完美世界) on Children’s day. 参加完美世界举办的48小时Game Jam时制作。
He received a Bachelor's degree in Computer Science and Engineering from MIT (Course 6-3, for those in the know) and a Master’s degree in Computer Science from Johns Hopkins University. Phil is ...
Ian would like to thank his wife and children for not whining too loudly, and Fletcher for putting up with his procrastination. He would also like to thank Douglas Adams for the herring sandwich scoop...
All widgets and panels can now anchor to each other, the screen, and even 3D game objects. - NEW: You can now create resizable scroll views and anchor them to UI elements. - NEW: Re-created the ...
It's a whole new ball game for me. 這對我來說是個全新的球類遊戲。 He's sleeping like a baby. 他正睡着,像个婴儿一样。 He can play both tennis and baseball. 他既会打网球,又会打棒球。 We should cancel ...
Factors associated with the accuracy of self-reported high-school grades 364 RICHARD R. ABIDIN REFERENCES ...children’s behavior. American Journal of Orthopsychiatry, 1971, 41, 48
Address List: When the option to deactivate children is set, the children will get deactivated first Memory Scan: Add a lua script in autorun that lets you specify which module to scan Lua: ...
A native of Louisville, Kentucky, he now lives with his wife and three children in Lake Mary, Florida. When not programming or dodging hurricanes, Richard is an avid amateur astronomer and an Adult ...
Factors associated with the accuracy of self-reported high-school grades 364 RICHARD R. ABIDIN REFERENCES ...children’s behavior. American Journal of Orthopsychiatry, 1971, 41, 48
( ) 3.There will be a soccer game _______ the morning of June 15 ? A. in B. on C. at D. / ( )4. Young Tom ______all his free time playing baseball for the school team . A. pays B. takes C. spends D....
Waypoint master unity unity3d免费寻路插件; To use it you should attach ... All this waypoints should be children of WyapointMaster game object. And you can use this script as you wish, it's free.
Information Theory for Intelligent ...Shannon Distance 1110 A Note on Measuring Information 1211 Minds and Information 131 Twenty QuestionsThe story of information theory begins with the children’s game
C)To resign from his position in the woman's company. D)To exchange stock market infotmation with the woman. <br>20. A)He is head of a small teading company. B)He works in an ...
JAVA模版引擎Freemarker常用标签(一) 1. if指令 这是一个典型的分支控制指令,该指令的作用完全类似于Java语言中的if,if指令的语法格式如下: <#if condition>... <#elseif condition>... <#elseif condition>......