Cod sursa(job #701646)

Utilizator BugirosRobert Bugiros Data 1 martie 2012 17:01:06
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <cstdio>
using namespace std;

const int MAXTEXT = 1100000;

char text[MAXTEXT];
int nr_cuvinte,l_cuvinte;

void citire()
{
    freopen("text.in","r",stdin);
    freopen("text.out","w",stdout);
    gets(text);
}

void prelucrare()
{
    bool cuvant = false;
    for (int i = 0;text[i] != 0;++i)
        if((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i] <= 'Z'))
        {
            ++l_cuvinte;
            cuvant = true;
        }
        else if (cuvant)
        {
            ++nr_cuvinte;
            cuvant = false;
        }
    if (cuvant)
        ++nr_cuvinte;
}

int main()
{
    citire();
    prelucrare();
    printf ("%d",l_cuvinte / nr_cuvinte);
    return 0;
}