Pagini recente » Profil sebi212 | Monitorul de evaluare | Statistici Mocanu Diana Paula (MocanuDiana) | Monitorul de evaluare | 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);
}