Pagini recente » Cod sursa (job #1758158) | Cod sursa (job #1344792) | Cod sursa (job #1387480) | Arhiva de probleme | Cod sursa (job #114400)
Cod sursa(job #114400)
#include <stdio.h>
#include <string.h>
#define Nmax 1000001
int c[350], n, i, last=100, j;
char ch;
char jeg[Nmax], rez[Nmax];
int main()
{
freopen("ordine.in", "r", stdin);
scanf("%s", &jeg);
n=strlen(jeg);
for (i=0; i<n; i++) c[jeg[i]]++;
fclose(stdin);
freopen("ordine.out", "w", stdout);
for (i=0; i<n; i++)
{
for (j='a'; j<='z'; j++)
if (c[j] && j!=rez[i-1])
break;
rez[i]=j;
c[j]--;
}
printf("%s\n", rez);
fclose(stdout);
return 0;
}