Cod sursa(job #449770)

Utilizator bog29Antohi Bogdan bog29 Data 6 mai 2010 21:00:12
Problema Ordine Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<fstream>
#define dmax 1000004
using namespace std;
ifstream in("ordine.in");
ofstream out("ordine.out");

int n,y[30],ok;
char x[dmax],z[dmax],c;

int main()
{	int i,j;
	in>>x;
	in.close();
	n=strlen(x);
	for(i=0;i<n;i++)
		y[x[i]-'a']++;
	for(i=0;i<n;i++)
	{	ok=1;
		for(j=0;j<=27 && ok;j++)
			if(y[j])	
			{	c='a'+j;
				if(i==0 || c!=z[i-1])
				{	z[i]=c;
					y[j]--;
					ok=0;
				}	
		}	
	}
	//z[n]=NULL;
	out<<z;
	out.close();
	return 0;
}