Cod sursa(job #348504)

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

   if(cv!=0)
   {
cout<<nr<<' '<<cv<<endl<<nr/cv<<endl;
   y<<nr/cv<<endl;
   }
   y.close();
    x.close();
   cout<<p;
   return 0;
}