Pagini recente » Infoarena Monthly 2012 - Clasament | Cod sursa (job #606862) | Cod sursa (job #407022) | Cod sursa (job #1603457) | Cod sursa (job #891537)
Cod sursa(job #891537)
#include <stdio.h>
#include <stdlib.h>
int main(void) {
FILE *f = fopen("text.in", "r");
int in_word = 0, word_count = 0, letter_count = 0;
char c;
do {
c = fgetc(f);
if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
in_word = 1;
letter_count++;
} else {
if(in_word == 1) {
word_count++;
in_word = 0;
}
}
} while(c != EOF);
fclose(f);
f = fopen("text.out", "w");
fprintf(f,"%d",letter_count / word_count);
fclose(f);
return 0;
}