Cod sursa(job #2314058)

Utilizator Darkknight4433Gaspar Tamas Darkknight4433 Data 7 ianuarie 2019 20:19:34
Problema Text Scor 0
Compilator cpp-32 Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <bits/stdc++.h>

using namespace std;
ifstream in("fact.in");
ofstream out("fact.out");



int main()
{
    int cnt = 0,chars = 0;
    vector <string> v;
    string word;
    while (in >> word)
    {
        auto it = word.begin();
        if (word != "-")
            ++cnt;
        while (it != word.end())
        {
            if (*it == '-')
            {
                word.erase(it);
            if (it == word.begin())
                ++cnt;
            }else
            if (ispunct(*it))
                word.erase(it);
            else
                ++it;
        }

        v.push_back(word);
    }

    for (int i = 0; i < v.size();i++)
        chars += v[i].size();
    out << endl << chars/cnt;

}