Cod sursa(job #1554786)

Utilizator pitradaPit-Rada Ionel-Vasile pitrada Data 21 decembrie 2015 18:59:57
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.55 kb
#include <fstream>
#include <cstring>
using namespace std;
ifstream f("text.in");
ofstream g("text.out");
char s[1200000],*p,sep[200],ch;
int l=0,nr=0;
int main ()
{
    for(ch=32;ch<=126;ch++)
      if(!((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')))
      {
         sep[l]=ch;
         l++;
      }
    sep[l]=0;
    l=0;
    while(f.get(s,1200000))
    {
      p=strtok(s,sep);
      while (p!=NULL)
      {
        nr++;
        l=l+strlen(p);
        p=strtok(NULL,sep);
      }
    }
    g<<l/nr;
    g.close();
    return 0;
}