Cod sursa(job #2483324)

Utilizator PrelipceanRazvanPrelipcean Razvan Mihai PrelipceanRazvan Data 29 octombrie 2019 17:49:09
Problema Text Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <fstream>
#include <string.h>

using namespace std;

ifstream in("text.in");
ofstream out("text.out");
string prop, aux;
int words = 1, letters, i;
bool start = false;

bool isChar(char a){
  return ((a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z'));
}

int main(){
  prop = "";
  in >> aux;
  while(!in.eof()){
    prop += aux + " ";
    in >> aux;
  }
  for(i = 0; i < prop.size(); i++){
    if(isChar(prop[i])){
      letters++;
      start = true;
    }
    else{
      if(start && isChar(prop[i + 1])){
        words++;
      }
    }
  }
  out << letters / words;
  return 0;
}