Cod sursa(job #388184)

Utilizator bog29Antohi Bogdan bog29 Data 29 ianuarie 2010 15:59:24
Problema Ordine Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.54 kb
#include<fstream>
#define dmax 1000004

using namespace std;
ifstream in("ordine.in");
ofstream out("ordine.out");

char x[dmax];
long int n,t;

int sort_function(const void *a,const void *b)
{	return strcmp((char*)a , (char*)b);
}
int main()
{	int i,j;
	in>>x;
	in.close();
	n=strlen(x);
	qsort((void*)x,n,sizeof(x[0]),sort_function);
	i=0;
	while(i<n)
	{	if(x[i]==x[i-1])
		{	j=i+1;
			while(x[i]==x[j])
				j++;
			t=x[i];
			x[i]=x[j];
			x[j]=t;
			i--;
		}
		i++;
	}
	out<<x;	
	out.close();
	return 0;
}