Cod sursa(job #1274209)

Utilizator hopingsteamMatraguna Mihai-Alexandru hopingsteam Data 23 noiembrie 2014 16:16:22
Problema Ordine Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.87 kb
#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;
}