Cod sursa(job #2770974)
| Utilizator | Data | 24 august 2021 15:27:36 | |
|---|---|---|---|
| Problema | Text | Scor | 0 |
| Compilator | c-32 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <stdio.h>
#include <ctype.h>
int main() {
FILE* f = fopen("text.in.txt","r");
if(f == NULL)
return -1;
char c;
int litere = 0;
int cuvinte = 0;
while(fscanf(f,"%c",&c)!=EOF){
if(isalpha(c))
litere++;
if(litere > 0)
if(c ==' ' || c == ',' || c == '-')
cuvinte++;
}
int med = litere/cuvinte;
FILE* f2 = fopen("text.out.txt","w");
fprintf(f2,"%d", med);
fclose(f);
fclose(f2);
return 0;
}
