Cod sursa(job #2609242)

Utilizator robertnanu_fmiNanu Robert-Ionut robertnanu_fmi Data 2 mai 2020 12:46:08
Problema Text Scor 100
Compilator cpp-64 Status done
Runda igorj_mentorat1 Marime 0.98 kb
#include <fstream>
#include <string>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
string s;
int main()
{
   long long nlitere =0, nr_cuvinte =0, ntotal = 0 ;
   bool ok = 0;
   long long i =0;
   while(fin>>s)
   {
        int i = 0;
        ok =0;
        while(i < s.size())
       {
       if((s[i]>= 'a' && s[i]<='z' )||(s[i]>='A' && s[i]<='Z'))
       {
           if(ok == 0)
           {
              ok =1;
              nlitere = 1;
           }
           else
            nlitere++;
       }
       else
       {
           if(ok == 1)
           {
               ntotal = ntotal + nlitere;
               nr_cuvinte++;
              ok = 0;
           }
       }
       i++;
      }
      if(ok == 1)
      {
          ntotal = ntotal + nlitere;
          nr_cuvinte++;
      }
   }
    if(nr_cuvinte == 0)
    {
       fout<<0<<"\n";
       return 0;
    }
    fout<<ntotal / nr_cuvinte<<"\n";
    return 0;
}