Cod sursa(job #2663640)

Utilizator cristi_macoveiMacovei Cristian cristi_macovei Data 26 octombrie 2020 22:32:55
Problema Text Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <iostream>
#include <fstream>
#include <string>

int main() {
  std::ifstream in("text.in");
  std::ofstream out("text.out");
  std::string str;

  std::getline(in, str);

  int words = 0, len = isalpha(str[0]);
  for (int i = 1; i < (int)str.size(); ++i) {
    if (isalpha(str[i]))
      ++len;
    else if (isalpha(str[i - 1]))
      ++words;
  }
  if (isalpha(str.back()))
    ++words;

  out << len / words << '\n';

  out.close();
  return 0;
}