Cod sursa(job #2197225)

Utilizator stefanchistefan chiper stefanchi Data 21 aprilie 2018 14:14:31
Problema Text Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.67 kb
#include <cstdio>
#include <cstring>

using namespace std;

void findWords(int &numberWords, int &numberChar ,int &numberSpaces)
{
    char currentChar, lastChar = '\n';
    while( scanf("%c",&currentChar) == 1)
    {
        numberChar++;
        if(strchr("-,?!. \n",currentChar))
        {
            numberSpaces++;
            if(strchr("-,?!. \n",lastChar) == NULL)
                numberWords++;
        }
        lastChar = currentChar;
    }
}

int main()
{
    int nmbW = 0, nmbC = 0 , nmbS = 0;
    freopen("text.in","r",stdin);
    freopen("text.out","w",stdout);
    findWords(nmbW,nmbC,nmbS);
    printf("%d",(nmbC-nmbS)/ nmbW);
    return 0;
}