Cod sursa(job #2372328)

Utilizator alexghitaAlexandru Ghita alexghita Data 7 martie 2019 03:16:22
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.5 kb
#include <bits/stdc++.h>

using namespace std;

int main() {
  freopen("text.in", "r", stdin);
  freopen("text.out", "w", stdout);

  char c;
  int num_of_words = 0;
  int total_word_length = 0;
  int current_word_length = 0;

  while (cin.get(c)) {
    if (!isalpha(c)) {
      if (current_word_length) {
        num_of_words++;
        total_word_length += current_word_length;
      }
      current_word_length = 0;
    } else {
      current_word_length++;
    }
  }

  cout << total_word_length / num_of_words;
}