Pagini recente » Cod sursa (job #1225592) | Cod sursa (job #3138541) | Cod sursa (job #2285565) | Cod sursa (job #672981) | Cod sursa (job #674973)
Cod sursa(job #674973)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
FILE *f=fopen("text.in","r"),*p=fopen("text.out","w");
char *s,*sep,*a;
int i,l=0,nr=0;
sep=" 1234567890~`!@#$%^&*()_{}[]|\'><+=\"?:;',.-";
s=malloc(100000*sizeof(char));
while(fgets(s,100000,f)!=NULL){
for(i=0;i<strlen(s);i++)
if(isalpha(s[i])) l++;
a=strtok(s,sep);
if (a!=NULL) nr++;
while (a!=NULL)
{nr++;
a=strtok(NULL,sep);
}
nr=nr-2;
}
if(nr>0) fprintf(p,"%d",l/nr);
else fprintf(p,"0");
fclose(f);
fclose(p);
return 0;
}