Cod sursa(job #1821213)

Utilizator medicinedoctoralexandru medicinedoctor Data 2 decembrie 2016 19:51:27
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <fstream>

using namespace std;

string s,s0;

bool ch(char x)
{
    return ( ((x>='a') && (x<='z')) || ((x<='Z') && (x>='A')) );
}

main()
{
    ifstream fin("text.in");
    while (!fin.eof())
    {
        getline(fin,s0);
        s+=" "+s0+" ";
    }
    fin.close();
    int w=0,c=0,q=0; char x;
    for (int i=0; i<s.size(); i++)
    {
        x=s[i];
        if (ch(x)) c++; else
        {
            q+=c;
            if (c!=0) w++;
            c=0;
        }
    }
    ofstream fout("text.out");
    fout<<(q+c)/w;
    fout.close();
}