Cod sursa(job #439734)
Utilizator | Dani Biro Daninet | Data | 11 aprilie 2010 18:50:31 |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <cstdio>
#include <cmath>
int main() {
FILE *f,*g;
f = fopen("text.in","r");
g = fopen("text.out","w");
long int nc=0,tw=0; //tw-szavak szama, nc-betuk szama
char c;
bool inword = false;
fscanf(f,"%c",&c);
while (c!=EOF) {
if ((c>64 && c<91)||(c>96 && c<123)) {
nc++;
inword = true;
}
else if (inword)
{
tw++;
inword = false;
}
c = fgetc(f);
}
if (inword) tw++;
fprintf(g,"%d",(int)(nc/tw));
fclose(f);
fclose(g);
return 0;
}