Pagini recente » Cod sursa (job #1765914) | Cod sursa (job #1007150) | Cod sursa (job #2177440) | Cod sursa (job #972391) | Cod sursa (job #2429920)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main() {
FILE *fp = fopen("text.in", "r");
int total_length = 0;
int no_of_words = 0;
int ok = 0;
char c;
while ((c = fgetc(fp)) != EOF)
if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z') {
total_length++;
if (!ok) {
no_of_words++;
ok = 1;
}
}
else
ok = 0;
fclose(fp);
int res = total_length / no_of_words;
fp = fopen("text.out", "w");
fprintf(fp, "%d", res);
fclose(fp);
}