Cod sursa(job #1105116)

Utilizator MoneaVladMonea Vlad MoneaVlad Data 11 februarie 2014 14:36:00
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.76 kb
#include <iostream>
#include <fstream>
#include <string.h>

using namespace std;

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

char s[2000001];

int ver(char c)
{
    if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
        return 1;
    else
        return 0;
}

int main()
{
    int l, ok, i, k, cuv;
    in.get(s, 2000001, '\n');
    l = strlen(s);
    k = 0;
    ok = 0;
    cuv = 0;
    for (i = 0; i < l; i++)
    {
        if (ver(s[i]))
        {
            k++;
            if (ok == 0)
            {
                cuv++;
                ok = 1;
            }
        }
        else
        {
            ok = 0;
        }
    }
    out << k/cuv << "\n";
    in.close();
    out.close();
    return 0;
}