Cod sursa(job #2140301)

Utilizator armigheGheorghe Liviu Armand armighe Data 23 februarie 2018 11:09:18
Problema Litere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 kb
#include<fstream>
#include<vector>
using namespace std;
ifstream f("litere.in");
ofstream g("litere.out");
char s[10002];
int v[30];
int main()
{
    int n,i,sol=0,j;
    f>>n;
    f.get();
    f.getline(s,10001);
    for(i=0;i<n;i++)
    {
        v[s[i]-'a'+1]++;
        for(j=s[i]-'a'+2;j<=26;j++)
            sol+=v[j];
    }
    g<<sol;
    return 0;
}