Cod sursa(job #1363943)

Utilizator jeffpascalJean Francois jeffpascal Data 27 februarie 2015 13:05:13
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 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;

void prelucrare (char p[])
{
    int ok=0;
    for (int i=0 ; i < strlen (p); i++)
    {
        if ((p[i]>='a' && p[i]<='z' ) || (p[i]>='A' && p[i]<='Z') )
            {continue;
            ok=1;
            }
            else sum--;
    }
    if (ok==1)
    count++;
}

int main ()
{
    char s[10000];
    fin.getline(s,10000);

    char *p;


    p = strtok (s," ");

    while (p)
    {
        sum = sum + strlen (p);

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