Cod sursa(job #179142)
| Utilizator | Data | 15 aprilie 2008 18:14:29 | |
|---|---|---|---|
| Problema | Ordine | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include<stdio.h>
FILE *f=fopen("ordine.in","r");
FILE *g=fopen("ordine.out","w");
long v[33];
void cit()
{
char c;
while(!feof(f))
{fscanf(f,"%c",&c);
++v[int(c)-97];
}
--v[int(c)-97];
}
void solve()
{
int x,y;
x=0;
while(!v[y])
++x;
y=x+1;
while(v[x])
{fprintf(g,"%c",x+97);
--v[x];
while(v[x]&&v[y])
{fprintf(g,"%c%c",char(y+97),char(x+97));
--v[x];
--v[y];
}
x=y;
y=y+1;
}
if(v[x-1])
fprintf(g,"%c",x+96);
}
int main()
{
cit();
solve();
fcloseall();
return 0;
}