Pagini recente » Cod sursa (job #2386638) | Diferente pentru runda/prosoft2016-9 intre reviziile 5 si 4 | Cod sursa (job #1260974)
#include <stdio.h>
#include <conio.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);
}