Cod sursa(job #348914)
#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+2];
if(!p)
{
cout<<"Dynamic memory couldn't be allocated";
return -1;
}
x.getline(p,n+1);
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;
}