Mai intai trebuie sa te autentifici.
Cod sursa(job #891537)
Utilizator | Data | 25 februarie 2013 17:38:58 | |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.62 kb |
#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;
}