Cod sursa(job #2605380)

Utilizator lepoartcevPaltineanu Rares-Mihai lepoartcev Data 24 aprilie 2020 20:19:56
Problema Text Scor 40
Compilator c-64 Status done
Runda Arhiva de probleme Marime 0.71 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

    FILE* in = fopen("text.in", "r");
    FILE* out = fopen("text.out", "w");

    char* text = (char*)malloc(1000000);

    fgets(text, 1000000, in);

    int size = strlen(text);

    int lWord = 0;
    int lText = 0;
    for(int i = 0; i < size; i++) {

        if((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z')) {

            while((text[i] != '\0' && text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z')) {

                  lWord++;
                  i++;

            }
            lText++;

        }
    }

    fprintf(out, "%d", lWord/lText);
    return 0;

}