Cod sursa(job #348467)

Utilizator TFifesPorcescu Alexandru TFifes Data 15 septembrie 2009 20:34:33
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include<iostream>
#include<string.h>
#include<fstream>
using namespace std;
int main ()
{
    ifstream x("text.in",ios::ate);
ofstream y("text.out");
   unsigned short n,nr=0,cv=0;
   n=x.tellg();
   x.seekg(0,ios::beg);
   char *p,*q,sep[]=" .,/!?@#$%^^&&&**()-_1234567890";
   p=new (nothrow) char [n+1];
   x.getline(p,n);
   x.close();
   q=strtok(p,sep);
   while(q)
   {
       nr+=strlen(q);
       cv++;
       q=strtok(NULL,sep);
   }
   if(cv!=0)
   {

   y<<nr/cv;
   }y.close();
   return 0;
}