Cod sursa(job #1554781)

Utilizator pitradaPit-Rada Ionel-Vasile pitrada Data 21 decembrie 2015 18:51:38
Problema Text Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 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;
    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;
}