Cod sursa(job #117016)
| Utilizator | Data | 20 decembrie 2007 12:07:07 | |
|---|---|---|---|
| Problema | Litere | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <stdio.h>
int n, v[30], contor, c;
char s[10004];
int main()
{
freopen("litere.in","r",stdin);
freopen("litere.out","w",stdout);
int i,j;
scanf("%d",&n);
scanf("%s",&s);
for (i = 1; i < 27; i++)
{
c = 0;
for (j = 0; j < n; j++)
if (s[j] == 'a' + i - 1) contor += c;
else if (s[j] > 'a' + i - 1) c++;
}
printf("%d\n",contor);
return 0;
}
