Pagini recente » Cod sursa (job #1157863) | Cod sursa (job #3182920) | Cod sursa (job #2687155) | Cod sursa (job #2734261) | Cod sursa (job #2306)
Cod sursa(job #2306)
#include <stdio.h>
#include <string.h>
#include <ctype.h>
char textln[300];
void nrsol(long &nrl,long &nrc)
{int i;
char *p,del[]=" ;.',/><=+-{}[]@#$%^&*()`~!?";
p=strtok(textln,del);
while(p)
{nrc++;
for(i=0;i<strlen(p);i++)
if(isalpha(p[i]))
nrl++;
p=strtok(0,del);
}
}
int main()
{FILE *fin=fopen("text.in","r");
long nrl=0,nrc=0,nr;
while(!feof(fin))
{fgets(textln,300,fin);
if(textln[strlen(textln)-1]=='\n')
textln[strlen(textln)-1]=NULL;
nrsol(nrl,nrc);
}
nr=nrl/nrc;
fclose(fin);
fin=fopen("text.out","w");
fprintf(fin,"%ld",nr);
fclose(fin);
return 0;
}