Cod sursa(job #2496950)

Utilizator Botzki17Botocan Cristian-Alexandru Botzki17 Data 21 noiembrie 2019 21:21:16
Problema Text Scor 60
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <fstream>
#include <string>
using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
string s;
int main()
{
   long long ncuv =0, nr_cuvinte =0, ntotal = 0 ;
   bool ok = 0;
   long long i =0;
   while(getline(fin, s))
   {
        int i = 0;
        while(i < s.size())
       {
       if((s[i]>= 'a' && s[i]<='z' )||(s[i]>='A' && s[i]<='Z'))
       {
           if(ok == 0)
           {
              ok =1;
              ncuv = 1;
           }
           else
            ncuv++;
       }
       else
       {
           if(ok == 1)
           {
               ntotal = ntotal + ncuv;
               nr_cuvinte++;
              ok = 0;
           }
       }
       i++;
      }
   }

    fout<<ntotal / nr_cuvinte<<"\n";
    return 0;
}