Cod sursa(job #792715)

Utilizator NexflameGeorge Pultea Nexflame Data 29 septembrie 2012 12:38:49
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

int clit (char *x)
{
    int c = 0;
    for (int i = 0; i < strlen(x); i++)
        if ((x[i] >= 'a' && x[i] <= 'z') || (x[i] >= 'A' && x[i] <= 'Z'))
            c++;
    return c;
}

int main()
{
    ifstream in ("text.in");
    ofstream out ("text.out");
    char* s;
    int sum = 0;
    s = new char[100000];
    in.getline(s, 100000);

    int c = 0;
    char *p = strtok(s, " ");
    while (p)
    {
        sum += clit(p);
        c++;
        p = strtok (NULL, " ");
    }
    out << sum / c;
    return 0;
}