Pagini recente » Cod sursa (job #1343557) | Cod sursa (job #64325) | Cod sursa (job #1705007) | Cod sursa (job #2058283) | Cod sursa (job #1274209)
#include <fstream>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
ifstream fin("ordine.in");
ofstream fout("ordine.out");
char word[1000005];
int appears[30];
int L, MaxLetter, MinLetter = 30;
void Sort()
{
int LastC = 0, aux;
while(MinLetter <= MaxLetter)
{
fout << (char)(MinLetter + 96);
LastC = MinLetter;
appears[MinLetter] -= 1;
if(appears[MinLetter] == 0)
MinLetter += 1;
}
}
void read()
{
fin >> word;
L = strlen(word);
for(int i = 0; i < L; i++)
{
int letter = (int)word[i] - 96;
appears[letter] += 1;
if(letter > MaxLetter)
MaxLetter = letter;
if(letter < MinLetter)
MinLetter = letter;
}
Sort();
}
int main()
{
read();
return 0;
}