Pagini recente » Cod sursa (job #283486) | Cod sursa (job #1680772) | Cod sursa (job #1667226) | Cod sursa (job #1830662) | Cod sursa (job #439734)
Cod sursa(job #439734)
#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;
}