Cod sursa(job #3371738)

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

    return 0;
}