Cod sursa(job #2383881)

Utilizator Catalin_CristianCatalin Cristian Catalin_Cristian Data 19 martie 2019 20:59:21
Problema Text Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.11 kb
#include <fstream>
#include <iostream>
using namespace std;

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

bool verif_spatiu(string a)
{
    for(int i=0; i<a.length(); i++)
        if(a[i]==' ')
          return true;
    return false;
}

bool verif_caracter(string a)
{
    for(int i=0; i<a.length(); i++)
        if(a[i]=='-')
          return true;
    return false;
}
int rezolva(string text)
{
    int nrcv=0, aux=0, c_aux=0, nrc, lm;
    for(int i=0; i<text.length(); i++)
        if(!((text[i]>='A' && text[i]<='Z') ||(text[i]>='a' && text[i]<='z')))
            aux++;

    nrc=text.length()-aux;

      for(int i=0; i<text.length(); i++)
            if(text[i]==' ')
            {
                nrcv++;
                while(text[i++]==' ');
            }
         nrcv+=1;
         if(verif_caracter(text))
            for(int i=0; i<text.length(); i++)
                if(text[i]=='-')
                   c_aux++;
         nrcv+=c_aux;

    lm=nrc/nrcv;
    return lm;
}

int main()
{
    string text;
    fin>>text;
    fout<<rezolva(text);
    return 0;
}