Cod sursa(job #947711)

Utilizator Coman95coman cosmin Coman95 Data 8 mai 2013 10:33:27
Problema Litere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <fstream>
#include <vector>
using namespace std;

ifstream fin("litere.in");
ofstream fout("litere.out");

int s[27];
int n, sum;
char a;

int main()
{
    int x;
    fin >> n;
    for( int i = 1; i <= n; ++i )
    {
        fin >> a;
        x = a - 'a';
        s[x]++;
        for( int j = x+1; j <= 26; ++j )
            sum += s[j];
    }
    fout << sum << ' ';
    fin.close();
    fout.close();
    return 0;
}