Cod sursa(job #1722269)

Utilizator Adrian9602Adrian Cucu Adrian9602 Data 27 iunie 2016 19:24:04
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.8 kb
#include    <iostream>
#include    <fstream>

using namespace std ;


int lungime_cuvinte ;
int numar_cuvinte ;

bool isLetter( char ch )
{
    if ( (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') )
        return 1 ;


    return  0 ;

}

int main()
{
    FILE *fi = fopen( "text.in" , "r"  ) ;
    FILE *fo = fopen( "text.out" , "w" ) ;

    char ch ;
    bool ok ;

    while(  (ch = fgetc(fi) )!= EOF  )
    {
        if(isLetter( ch ))
        {
            ++ lungime_cuvinte ;
            ok = 1 ;
        }
            else if ( ok  )
            {
                ok = 0 ;
                ++ numar_cuvinte ;

            }
     }


    fprintf( fo , "%i\n" , lungime_cuvinte / numar_cuvinte   ) ;


    fclose(fi) ;
    fclose(fo) ;

    return  0 ;
}