Mai intai trebuie sa te autentifici.
Cod sursa(job #1260974)
Utilizator | Data | 11 noiembrie 2014 20:21:38 | |
---|---|---|---|
Problema | Text | Scor | 0 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.66 kb |
#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);
}