Cod sursa(job #2483310)

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

using namespace std;

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

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

int main(){
  getline(in, prop);
  for(i = 0; i < prop.size(); i++){
    if(isChar(prop[i])){
      letters++;
      start = true;
      if(first){
        words++;
        first = false;
      }
    }
    else{
      if(start && isChar(prop[i + 1])){
        words++;
      }
    }
  }
  if(!letters){
    out << 0;
    return 0;
  }
  out << letters / words;
  return 0;
}