Pagini recente » Cod sursa (job #2770848) | Cod sursa (job #116863) | Istoria paginii utilizator/uwuenvy | Cod sursa (job #2225720) | Cod sursa (job #1260977)
#include <stdio.h>
void main () {
FILE *f;
f = fopen("text.in","r");
int c;
int characters = 0;
int words = 0;
int others = 0;
int state = 0;
while ((c = fgetc(f)) != EOF) {
if(state == 0) {//cauta inceputul cuvintelor
if((c >= 65 && c <=90) || (c >= 97 && c <= 122 )){
words++;
characters++;
state = 1;
}
}else if(state == 1){//parcurge cuvantul
if(((c >= 65 && c <=90) || (c >= 97 && c <= 122 ))){
characters++;
}else {
state = 0;
}
}
}
fclose(f);
f = fopen("text.out","w");
fprintf(f,"%d" ,characters/words);
fclose(f);
}