Cod sursa(job #40421)
Utilizator | Oana nasti Nasti | Data | 27 martie 2007 13:53:04 |
---|---|---|---|
Problema | Text | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.39 kb |
#include<stdio.h>
#include<ctype.h>
int main()
{
FILE*f=fopen("text.in","r");
FILE*g=fopen("text.out","w");
char c,c1;
long nrl,nrc;
fscanf(f,"%c",&c);
if(isalpha(c))
nrl++;
else
nrl=0;
nrc=1;
while(!feof(f))
{fscanf(f,"%c",&c1);;
if(isalpha(c1))
nrl++;
if(c==' '&&isalpha(c1))
nrc++;
c=c1;
}
fprintf(g,"%ld",nrl/nrc);
fclose(f);
fclose(g);
return 0;
}