Pagini recente » Cod sursa (job #93085) | Cod sursa (job #460545) | Rating Jesus R (JesusR) | Cod sursa (job #1723809) | Cod sursa (job #1520288)
#include <iostream>
#include <fstream>
using namespace std;
const int maxalpha = 26;
const int maxn = 10005;
int fr[maxalpha];
char s[maxn];
int main()
{
ifstream fin("litere.in");
ofstream fout("litere.out");
int n;
fin >> n;
fin >> s;
int rasp = 0;
for(int i = 0 ; i < n ; ++ i) {
++ fr[s[i] - 'a'];
for(int j = s[i] - 'a' + 1 ; j < maxalpha ; ++ j) { /// iau toate caracterele mai mici strict ca numarul meu
rasp += fr[j];
}
}
fout << rasp << '\n';
return 0;
}