Cod sursa(job #1722273)

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

std::ifstream fin  ;
std::ofstream fout ;


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" ) ;

    fin.open( "text.in" , std::ios::in ) ;
    fout.open( "text.out" , std::ios::out ) ;

    char ch ;
    bool ok ;

    while( fin.get(ch) )
    {
        if(isLetter( ch ))
        {
            ++ lungime_cuvinte ;
            ok = 1 ;
        }
            else if ( ok  )
            {
                ok = 0 ;
                ++ numar_cuvinte ;

            }
     }


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

    fout << ( lungime_cuvinte / numar_cuvinte ) << '\n' ;

    //fclose(fi) ;
    //fclose(fo) ;
    fin.close() ;
    fout.close() ;


    return  0 ;
}