Cod sursa(job #1455691)
Utilizator | Data | 28 iunie 2015 21:00:11 | |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.41 kb |
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
FILE *f1 = fopen("text.in", "r");
FILE *f2 = fopen("text.out", "w");
long nr_cuv = 0;
long lung_t = 0;
char c;
int z;
while((c = fgetc(f1)) != -1) {
if(isalpha(c) == 0) {
if(z == 1) {
z = 0;
nr_cuv++;
}
}
else {
z = 1;
lung_t++;
}
}
fprintf(f2, "%ld\n", lung_t/nr_cuv);
fclose(f1);
fclose(f2);
return 0;
}