Cod sursa(job #2364514)

Utilizator DreeyBurlacu Andrei Dreey Data 4 martie 2019 09:26:39
Problema Litere Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <bits/stdc++.h>

using namespace std;

ifstream in("litere.in");
ofstream out("litere.out");

int main()
{
    int n;
    in >> n;
    char c;
    int v[10001];
    int vf = 0;
    int contor = 0;
    while(in >> c)
    {
        v[++vf] = c;
        int auxvf = vf;
        while(v[vf] - 'a' < v[vf-1] - 'a')
        {
            swap(v[vf],v[vf-1]);
            auxvf--;
            contor++;
        }
    }
    out << contor
    return 0;
}