Cod sursa(job #179130)

Utilizator n_lichkingSentes Norbert n_lichking Data 15 aprilie 2008 18:06:30
Problema Ordine Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 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[x])
    ++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;
  }



}


int main()
{
cit();
solve();

fcloseall();
return 0;

}