NUMCON - Ghép số lớn

Tác giả: hieult

Ngôn ngữ: C++

#include <cstdio>
#include <cstring>
//#include <conio.h>

int main()
{
    //freopen("NUMCON.in","r",stdin);
    char s[201][101];
    int n = 0;
    while(scanf("%s",s[++n])>0);
    for(int i = 1;i<=n;i++)
        for(int j = i+1;j<=n;j++)
        {
             char u[201],v[201];
             strcpy(u,s[i]);
             strcpy(v,s[j]);
             strcat(u,s[j]);
             strcat(v,s[i]);
             if(strcmp(u,v)<0)
             {
                 strcpy(u,s[i]);
                 strcpy(s[i],s[j]);
                 strcpy(s[j],u);
             }
        }
    for(int i = 1;i<=n;i++)
        printf("%s",s[i]);
   // getch();
}

Download