Cod sursa(job #882384)
| Utilizator | Data | 19 februarie 2013 02:25:39 | |
|---|---|---|---|
| Problema | Text | Scor | 100 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <stdio.h>
#include <string.h>
int main() {
freopen("text.in", "rt", stdin);
freopen("text.out", "wt", stdout);
int word_length, total_length, word_number;
char c;
word_number = 0;
total_length = 0;
word_length = 0;
while (scanf("%c", &c) != EOF) {
if (isalpha(c)) {
word_length++;
total_length++;
} else if (word_length != 0) {
word_number++;
word_length = 0;
}
}
printf("%d", total_length / word_number);
return 0;
}