Cod sursa(job #2197230)

Utilizator stefanchistefan chiper stefanchi Data 21 aprilie 2018 14:22:04
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <cstdio>

using namespace std;

void findWords(int &numberWords, int &numberChar)
{
    char currentChar;
    bool foundword = false;
    while( scanf("%c",&currentChar) == 1)
    {
        if( currentChar >='a' && currentChar <='z' || currentChar >='A' && currentChar <='Z')
        {
            numberChar++;
            foundword = true;
        }
        else if (foundword == true)
        {
            numberWords++;
            foundword = false;
        }
    }
}

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