Cod sursa(job #1619198)
Utilizator | Data | 28 februarie 2016 13:39:14 | |
---|---|---|---|
Problema | Ordine | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("ordine.in");
ofstream fout("ordine.out");
char s[1000005],x,y;
int i,a[30],n,j;
int main()
{fin>>s;
n=strlen(s);
for(i=0;i<n;++i)
{a[s[i]-96]++;
}
n=strlen(s);
for(i=0;i<n;++i)
{for(j=1;j<=26;j++)
{x=j+96;
if(a[j]>0&&y!=x){a[j]--;y=x;fout<<x;break;}
}
}
}