Cod sursa(job #2638285)

Utilizator andrei42Oandrei42O andrei42O Data 27 iulie 2020 17:31:23
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
char s[1<<19];
int64_t nr_cuvinte, litere;
bool litera(char);
int main()
{
    f.getline(s, sizeof(s));
    for(unsigned int i = 0; i < strlen(s); i++)
        if(litera(s[i]))
        {
            nr_cuvinte++;
            while(litera(s[i]) && i < strlen(s))
                litere++, i++;
            i--;
        }
    g << litere / nr_cuvinte;
    return 0;
}
bool litera(char c)
{
    return (c >= 'a' && c <= 'z')||(c >= 'A' && c <= 'Z');
}