Mai intai trebuie sa te autentifici.

Cod sursa(job #967033)

Utilizator toranagahVlad Badelita toranagah Data 26 iunie 2013 22:45:03
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <cctype>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;

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

int main() {
  unsigned int words_length = 0;
  unsigned int num_words = 0;
  char ch;
  while (!fin.eof()) {
    fin.get(ch);
    if (isalpha(ch)) {
      ++num_words;
      while (isalpha(ch)) {
        ++words_length;
        if (fin.eof()) break;
        fin.get(ch);
      }
    }
  }
  
  fout << words_length / num_words;
  return 0;
}