Cod sursa(job #1369609)

Utilizator jeffpascalJean Francois jeffpascal Data 3 martie 2015 10:08:37
Problema Text Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.75 kb
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;

ifstream fin ("text.in");
ofstream fout ("text.out");
int sum=0;
int count=0;
char s[1000001];
char *p;
void prelucrare (char p[])
{
    int ok;
    ok=0;
    int n = strlen ( p);
    for (int i=0 ; i < n; i++)
    {
        if ((p[i]>='a' && p[i]<='z' ) || (p[i]>='A' && p[i]<='Z') )
            {
                ok=1;
                continue;

            }
            else sum--;
    }
    if (ok==1)
    count++;
}

int main ()
{


while (fin.getline(s,10000))
{

    p = strtok (s," ");

    while (p)
    {
        sum = sum + strlen (p);
        prelucrare (p);
        p=strtok (NULL, " ");
    }
    fout <<sum/count;
}
}