Cod sursa(job #188572)

Utilizator firewizardLucian Dobre firewizard Data 8 mai 2008 22:46:49
Problema Ordine Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include <stdio.h>
#include <string>
#define FOR(i,s,d) for(i=(s);i<=(d);++i)
char c[10000005],sir[10000005];
long v[30],n,i,j,x;
int main()
{
    freopen ("ordine.in","r",stdin);
    freopen ("ordine.out","w",stdout);
    scanf("%s",&c);
    x=strlen(c);
    FOR (i,0,x-1)v[c[i]-96]++;
    FOR (i,1,x)
        FOR (j,1,26)
            if (j+96!=sir[i-1]&&v[j]>0)
               {sir[i]=j+96;v[j]--;break;}
    FOR(i,1,x)
    printf("%c",sir[i]);
    printf("\n");
    /*c[2]=' ';
    printf("%ld",c[2]);*/
    return 0;
}