Cod sursa(job #2128389)

Utilizator The4EverRadu Catalin-Gabriel The4Ever Data 11 februarie 2018 17:52:52
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.66 kb
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

ifstream f("text.in");
ofstream g("text.out");

int isLetter(char ch) {
    if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) {
        return 1;
    } else {
        return 0;
    }
}

int main()
{
    char s[50];
    int numar_cuvinte = 0,litere=0;

    f.get(s, 50);

    for(int i = 0; i <= strlen(s); i++) {
        if(isLetter(s[i])) litere++;
        if(( isLetter(s[i]) && !isLetter(s[i+1]) ) || i == strlen(s)-1 ) {
            numar_cuvinte++;
        }
    }

    g<<litere/numar_cuvinte;

    f.close();
    g.close();
    return 0;
}