Cod sursa(job #549995)

Utilizator DevilShadowJunc Raul Cosmin DevilShadow Data 9 martie 2011 09:42:36
Problema Litere Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.37 kb
#include <iostream>
#include <fstream.h>

int main()
{
	ifstream f ("litere.in");
	ofstream g ("litere.out");
	
	char s[10005], aux;
	int n, i, contor = 0, j, k, alf[26] = {};
	bool ok = true;
	
	f >> n;
	f >> s;
	
	for(i = 0; i < n; i ++)
	{
		k = s[i] - 97;
		alf[k] ++;
		for(j = k + 1; j < 26; j ++)
			if(alf[j] > 0)contor += alf[j];
	}
	g << contor;
}