Cod sursa(job #780040)
Utilizator | Chivu Stefan Iulian aranhil | Data | 19 august 2012 18:26:02 |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <stdio.h>
#include <ctype.h>
int main() {
FILE *f = fopen("text.in", "r");
FILE *g = fopen("text.out", "w");
int total = 0, cuvinte = 0, litc, afc = 0;
fscanf(f, "%c", &litc);
while(!feof(f)) {
printf("%c ", litc);
if(isalpha(litc)) {
total++;
afc = 1;
}
else if(afc) {
cuvinte++;
afc = 0;
}
fscanf(f, "%c", &litc);
}
fprintf(g, "%d", total / cuvinte);
fclose(f);
fclose(g);
}