Cod sursa(job #3369134)

Utilizator bucurmihneaBucur Mihnea David bucurmihnea Data 17 octombrie 2026 13:30:23
Problema Litere Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.34 kb
#include <fstream>
using namespace std;
ifstream fin("litere.in");
ofstream fout("litere.out");
int main()
{
    int n;
    char s[10001];
    fin >> n;
    fin >> s;
    long long nr = 0;
    for(int i = 0; i < n; i++)
        for(int j = i + 1; j < n; j++)
            if(s[i] > s[j]) nr++;
    fout << nr;

    return 0;
}