Cod sursa(job #757904)

Utilizator XladhenianGrigorita Vlad-Stefan Xladhenian Data 13 iunie 2012 18:59:24
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb

#include <fstream>
#include <string.h>
using namespace std;

char Data[1000005];

int main(void)
{
 fstream fin("text.in",ios::in);
 fstream fout("text.out",ios::out);
 long Count = 0;
 long W = 0;
 long Len = 0;
 long P = 0;
 long L = 0;
 while (fin >> Data)
  {
   W = 0;
   L = strlen(Data);
   for (P = 0;P < L;P += 1)
    {
     if (((Data[P] >= 'a') && (Data[P] <= 'z')) ||
         ((Data[P] >= 'A') && (Data[P] <= 'Z')))
       {
        Len += 1;
        W = 1;
       }
      else
       {
        if (W == 1)
          {
           Count += 1;
           W = 0;
          }
       }
    }
   Count += W;
  }
 if (Count == 0)
   {
    fout << 0;
   }
  else
   {
    fout << (Len / Count);
   }
 fin.close();
 fout.close();
 return 0;
}