Pagini recente » Cod sursa (job #3270133) | Cod sursa (job #3292793) | Cod sursa (job #2897960) | Cod sursa (job #2189886) | Cod sursa (job #674957)
Cod sursa(job #674957)
#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-1;
}
if(nr>0) fprintf(p,"%d",l/nr);
else fprintf(p,"0");
fclose(f);
fclose(p);
return 0;
}