Pagini recente » Cod sursa (job #1826189) | Monitorul de evaluare | Cod sursa (job #2784551) | Istoria paginii runda/yager | Cod sursa (job #1260987)
#include <stdio.h>
int main () {
FILE *f;
f = fopen("text.in","r");
int c;
int characters = 0;
int words = 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);
return 0;
}