Cod sursa(job #2523489)

Utilizator memecoinMeme Coin memecoin Data 14 ianuarie 2020 11:14:55
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.91 kb
#include <fstream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
#include <string.h>
#include <queue>

using namespace std;

#ifdef DEBUG
string name = "data";
#else
string name = "text";
#endif

ifstream fin(name + ".in");
ofstream fout(name + ".out");

int main() {
    
    string s((istreambuf_iterator<char>(fin)), (istreambuf_iterator<char>()));
    
    int l = 0;
    int nw = 0;
    bool didStartWord = false;
    
    
    for (int i = 0; i < s.length(); ++i) {
        char c = s[i];
        
        if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
            l++;
            didStartWord = true;
        } else {
            if (didStartWord) {
                didStartWord = false;
                nw++;
            }
        }
    }
    
    if (didStartWord) {
        nw++;
    }
    
    fout << l / nw;
    
    return 0;
}