Pagini recente » Cod sursa (job #2774723) | Cod sursa (job #7120) | Cod sursa (job #2853781) | Cod sursa (job #727610) | Cod sursa (job #455175)
Cod sursa(job #455175)
#include <algorithm>
#include <fstream>
using namespace std;
typedef char cha08;
typedef int int32;
const cha08 Input[] = "litere.in";
const cha08 Output[] = "litere.out";
const int32 Alf = 26;
const int32 Dim = 10001;
cha08 s[Dim];
int32 N, XXX;
int32 f[Alf];
int32 Que( int32 x ) {
int32 i, cnt;
for( i = x + 1, cnt = 0; i < Alf; ++i )
cnt += f[i];
return cnt;
}
int32 main() {
ifstream fin( Input );
ofstream fout( Output );
int32 i;
fin >> N;
fin.ignore( 1, '\n' );
fin.getline( s, Dim );
for( i = 0; i < N; ++i ) {
XXX += Que( s[i] - 'a' );
++f[s[i] - 'a'];
}
fout << XXX;
fin.close();
fout.close();
return 0;
}