Pagini recente » Cod sursa (job #2874219) | Clasament 28_februarie_simulare_oji_2024_clasele_11_12 | Istoria paginii runda/pre___oji___2018/clasament | Cod sursa (job #2138956) | Cod sursa (job #1722273)
//#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 ;
}