Cod sursa(job #2810675)

Utilizator MariusAndrei16Pricope Marius MariusAndrei16 Data 29 noiembrie 2021 22:44:45
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <iostream>
#include <fstream>
#include <cstring>

using namespace std;

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

int lenght, wordsN;

int main()
{   
    char text[1000000];
    in.get(text,999999);
    char *cuvant;
    cuvant = strtok(text," .,-!?123456789");
    while (cuvant != NULL)
    {
        lenght += strlen(cuvant);
        ++wordsN;
        cuvant = strtok(NULL," .,-!?123456789");
    }
    
    if(lenght == 0 || wordsN == 0)
        out << 0;
    else
        out << lenght / wordsN;

    return 0;
}