Cod sursa(job #734551)

Utilizator robertpoeRobert Poenaru robertpoe Data 14 aprilie 2012 15:35:06
Problema Litere Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.3 kb
#include<cstdio>
#include<fstream>
using namespace std;
ifstream f("litere.in");
ofstream g("litere.out");
int nr,n,i,j;
int a[100];
char s[10010];
int main()
{
	f>>n;
	f.get(s,10010);
	for(i=0;i<=n-1;i++)
	{
		for(j=s[i]-'a'+1;j<='z'-'a';j++)
			nr+=a[j];
		a[s[i]-'a']++;
	}
	g<<nr;
	return 0;
}