Cod sursa(job #2957187)

Utilizator nicu_ducalNicu Ducal nicu_ducal Data 21 decembrie 2022 21:45:33
Problema Text Scor 40
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.14 kb
#include <bits/stdc++.h>
using namespace std;

template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template <typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
using i64 = long long int;

const int INF = INT_MAX, MOD = 1e9 + 7;
const long long LINF = LLONG_MAX;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {0, 0, 0, -1, 1, -1, 1, 1, -1};
const int dy[] = {0, -1, 1, 0, 0, -1, 1, -1, 1};

int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  /// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  ifstream cin("text.in");
  ofstream cout("text.out");

  string text;
  getline(cin, text);
  i64 ans = 0, words = 0, now_len;

  text += " ";
  for (int i = 0; i < (int) text.size(); i++) {
    if (not isalpha(text[i])) continue;
    now_len = 0;
    while (isalpha(text[i])) {
      ++now_len;
      ++i;
    }

    ans += now_len;
    ++words;
  }

  cout << ans / words << "\n";

  return 0;
}