Cod sursa(job #2244385)

Utilizator stefanC19Stefan Cinca stefanC19 Data 22 septembrie 2018 17:47:51
Problema Text Scor 90
Compilator c Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <stdio.h>
#include <stdlib.h>

int main()
{   char ch;
    int numarCuvinte = 0;
    int esteCuvant = 0;
    int numarLitere = 0;
    FILE* f = fopen("text.in", "r");
    FILE* g = fopen("text.out", "w");
    while ((ch = fgetc(f)) != EOF)
    {
            if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
            {
                numarLitere++;
                esteCuvant = 1;
            }
            if (esteCuvant == 1 && (ch < 'A' || ch > 'z'))
            {
                numarCuvinte++;
                esteCuvant = 0;
            }
    }
    fprintf(g, "%d", numarLitere / numarCuvinte);
    return 0;
}