Cod sursa(job #1785791)

Utilizator CrystyAngelDinu Cristian CrystyAngel Data 21 octombrie 2016 22:58:56
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

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

char s[2000100];
long long n,i;

int main()
{
    fin.getline(s,2000100);
    n = strlen(s);
    long long suma=0;
    long long nr=0;
    for(i=0; i<n; ++i)
    {
        if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z'))
        {
            ++nr;
            ++i;
            ++suma;
            while((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z'))
            {
                ++suma;
                ++i;
            }
            --i;
        }
    }
    if(nr)
        fout<<suma/nr;
    else
        fout<<0;
}