Cod sursa(job #826431)

Utilizator rootlocusAlexandru Pana rootlocus Data 30 noiembrie 2012 18:07:41
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.57 kb
#include <stdio.h>
using namespace std;

bool is_alpha( char c )
{
	return ('a' <= c && c <= 'z') ||
		('A' <= c && c <= 'Z');
}

int main()
{
	stdin = freopen( "text.in", "r", stdin );
	stdout = freopen( "text.out", "w", stdout );
	int word_count = 0;
	int total_word_size = 0;
	bool inside_word = false;
	char c;

	while( scanf( "%c", &c ) == 1 )
	{
		if( is_alpha(c) )
		{
			inside_word = true;
			total_word_size += 1;
		}
		else
		{
			if( inside_word )
			{
				inside_word = false;
				word_count += 1;
			}
		}
	}

	printf( "%d", total_word_size / word_count );
	return 0;
}