Cod sursa(job #3005544)

Utilizator Radu_BicliBiclineru Radu Radu_Bicli Data 17 martie 2023 08:37:21
Problema Litere Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.35 kb
#include <bits/stdc++.h>

using namespace std;

ifstream fin("txt.in");
ofstream fout("txt.out");
int n, i, j, r;
char c[102];

int main() {
    fin >> n >> c;
    for(i = 0; i < n; i++) {
        for(j = i - 1; j >= 0; j--) {
            if(c[j + 1] < c[j]) swap(c[j + 1], c[j]), r++;
        }
    }
    fout << r;

    return 0;
}