Cod sursa(job #823335)

Utilizator antonioteoZait Teodor Antonio antonioteo Data 24 noiembrie 2012 21:41:14
Problema Text Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <fstream>
#include <cstring>
using namespace std;
const char iname[] = "text.in";
const char oname[] = "text.out";
ifstream fin(iname);
ofstream fout(oname);
char s[ 481624 ] , x;
int lg , i , j , lgt , nr_cuv , vs , verita;
void VeritaSerum ()
{
	while ( !fin.eof() )
	{
		fin.getline ( s ,  481624 );
		lg = strlen ( s );
		for ( i = 0; i < lg; ++i )
		{
			if ( s[ i ] >= 'a' && s[ i ] <= 'z' || s[ i ] >= 'A' && s[ i ] <= 'Z' )
			{
				++lgt;
				verita = 1;
			}
			else
			{
				if ( verita == 1 )
				{
					++nr_cuv;
					verita = 0;
				}
			}
		}
	}
}
int main()
{
	VeritaSerum ();
	if( nr_cuv > 0 && lgt > 0 )
		fout << lgt / nr_cuv << '\n';
	else
		fout << 0 << '\n';
	return 0;
}