Pagini recente » Cod sursa (job #1524334) | Cod sursa (job #1405837) | Cod sursa (job #2112805) | Cod sursa (job #1752736) | 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;
}