Cod sursa(job #2455695)

Utilizator CyborgSquirrelJardan Andrei CyborgSquirrel Data 12 septembrie 2019 15:22:09
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.59 kb
#include <iostream>
#include <fstream>

using namespace std;

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

bool test(char c)
{
    return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}

int main()
{
    char c;
    int words, chars;
    bool word = false;

    words = chars = 0;
    while(!fin.eof()){
        c = fin.get();
        if(test(c)){
            chars++;
            word = true;
        }else if(word){
            words++;
            word = false;
        }
    }
    //cout << words << " " << chars;
    fout << chars / words;
    return 0;
}