Cod sursa(job #1199876)

Utilizator mikeKiLL3rLupea Mihai Ionut mikeKiLL3r Data 20 iunie 2014 23:04:18
Problema Text Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.77 kb
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    char c;
    freopen("text.in", "r", stdin);
    freopen("text.out", "w", stdout);
    c = getc(stdin);
    int nrchar = 0;
    int nrcuv = 0;
    bool lastalfa = false;
    while(c != '\n')
    {
        if(c == ' ')
        {
           nrcuv++;
           lastalfa = false;
        }
        else if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
        {
            nrchar++;
            lastalfa = true;
        }
        else if(c == '-' && lastalfa==true)
        {
            nrcuv++;
            lastalfa = false;
        }
        c = getc(stdin);
    }
    int med = nrchar/nrcuv;
    printf("%i", med);
    return 0;
}