Cod sursa(job #1374342)

Utilizator m0mentRaducanu Andrei m0ment Data 5 martie 2015 08:19:59
Problema Text Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <fstream>
#include <cstring>
#define LGMAX 10000
#define LGMAXC 21
#define NMAXC 1001


using namespace std;
ifstream fin("text.in");
ofstream fout("text.out");
char s[LGMAX];
int nr,i,S;
char sep[]=" \n\t,;:?!-";

int main()
{
    char *p;
    nr=0;
    while(fin.getline(s,LGMAX,'.'))
    {
        p=strtok(s,sep);
        while(p)
        {
            nr++;
            S+=strlen(p);
            p=strtok(NULL,sep);
        }
    }
    fout<<S/nr;
    fout.close();
    return 0;
}