Cod sursa(job #165718)
Utilizator | Data | 26 martie 2008 17:52:57 | |
---|---|---|---|
Problema | Litere | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<stdio.h>
int v[27],i,n,j,s;
char x;
int main()
{
FILE*f=fopen("litere.in","r");
FILE*g=fopen("litere.out","w");
fscanf(f,"%d",&n);
fscanf(f,"%c",&x);
for (i=1;i<=n;i++)
{
fscanf(f,"%c",&x);
v[(int)x-97]++;
for (j=(int)x-96;j<=26;j++)
s+=v[j];
}
fprintf (g,"%d",s);
fclose(f);
fclose(g);
return 0;
}