Cod sursa(job #2553500)

Utilizator DDDECARRusu Dinu Stefan DDDECAR Data 22 februarie 2020 07:47:47
Problema Text Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <fstream>
#include <iostream>

using namespace std;

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

#define forbiddenCharSize 6

char forbiddenChars[forbiddenCharSize] = {'-', '.', '_', ',', '!', '?'};

int main()
{
    int total_Len = 0;
    int total_cuv = 0;
    string temp;
    while (in >> temp)
    {
        int size = temp.length();
        bool isWord = true;
        for (int i = 0; i < forbiddenCharSize; i++)
        {
            if (temp.find(forbiddenChars[i]) != string::npos)
            {
                isWord = false;
                break;
            }
        }
        if (isWord)
        {
            total_Len = total_Len + size;
            total_cuv++;
        }
    }
    out << (int)(total_Len / total_cuv);
    in.close();
    out.close();
    return 0;
}