Cod sursa(job #1364031)

Utilizator jeffpascalJean Francois jeffpascal Data 27 februarie 2015 13:45:09
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;

ifstream fin ("text.in");
ofstream fout ("text.out");

int main ()
{
    int count = 0;
    int sum = 0 ;
    int ok =0;
    int i , j ;
    int n;
    char s[10000];
    while (fin.getline(s,10000))
    {
        ok=0;
        n= strlen (s);
        count ++ ;
        for (i=0;i<n; i++)
        {
            if ((s[i]>='a' && s[i]<='z' ) || (s[i]>='A' && s[i]<='Z') )
            {
                sum++;
                ok++;
            }


        }

        for (j=0;j<n;j++)
        {
            if (s[j]==' ')
                count ++ ;
        }

    }
    if (count!=0)
    fout << sum/count;
    else fout << "0";
}