Cod sursa(job #743426)
Utilizator | Cimpu Cristina cristina.cimpu | Data | 4 mai 2012 12:10:55 |
---|---|---|---|
Problema | Text | Scor | 100 |
Compilator | c | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<stdio.h>
#include<string.h>
#define MAXLINIE 100
int main(){
int nr=0, litere=0, ok=1;
char c;
FILE *f, *g;
f = fopen("text.in","r");
g = fopen("text.out", "w");
if(f == NULL) perror ("error opening file");
else{
do{
c = fgetc(f);
if(isalpha(c)) {
litere++;
if(ok){
nr++;
ok = 0;
}
}
else ok = 1;
}while (c != EOF);
fprintf(g, "%d\n", litere/nr);
fclose(f);
fclose(g);
}
return 0;
}