Cod sursa(job #2810825)

Utilizator indianu_talpa_iuteTisca Catalin indianu_talpa_iute Data 30 noiembrie 2021 12:52:08
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <bits/stdc++.h>
#define MAX_SZ 1000000

using namespace std;

ifstream fin("text.in");
ofstream fout("text.out");

bool esteAlfabet(char n)
{
    return (n >= 'a' && n <= 'z') || (n >= 'A' && n <= 'Z');
}

int main()
{
    int sz, litere = 0, cuvinte = 0;
    char text[MAX_SZ];
    fin.getline(text, MAX_SZ);

    sz = (int)strlen(text);
    for (int i = 0; i < sz; i++)
    {
	while (!esteAlfabet(text[i]))
	    i++;

	cuvinte++;
	while (esteAlfabet(text[i]))
	{
	    litere++;
	    i++;
	}
    }

    fout << litere / cuvinte;
    return 0;
}