Cod sursa(job #947794)

Utilizator Johny_Depp22Johnny Depp Johny_Depp22 Data 8 mai 2013 15:43:13
Problema Litere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.38 kb
#include <fstream>
#include <cstring>

using namespace std;

ifstream f("litere.in");
ofstream g("litere.out");

int n, fcv[26], sol=0;
string s;

int main()
{
    f>>n; f>>s;

    for (int i=0; i<s.size(); i++)
    {
        ++fcv[s[i]-'a'];
        for (int j=s[i]-'a'+1; j<26; j++) sol+=fcv[j];
    }

    g<<sol<<'\n';

    f.close(); g.close();
    return 0;
}