Cod sursa(job #2344274)

Utilizator Razvan145Filea Razvan Razvan145 Data 14 februarie 2019 22:01:14
Problema Text Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.64 kb
#include <fstream>
#include <string>
#include <cctype>

using namespace std;

int main()
{
    ifstream input("text.in");

    string text;
    getline(input, text);

    int words = 0;
    int ct = 0;

    for (unsigned int i = 0u; i < text.size(); i++)
    {
        if (isalpha(text[i]))
        {
            words++;
            while (isalpha(text[i]) && text[i + 1] != '\0')
            {
                i++;
                ct++;
            }
        } else i++;
    }

    ofstream output("text.out");
    int result;
    if (words != 0)
        result = ct / words;

    output << result;


    return 0;
}