Cod sursa(job #355633)

Utilizator alutzuAlexandru Stoica alutzu Data 11 octombrie 2009 19:53:37
Problema Text Scor 100
Compilator cpp Status done
Runda CNRV #2 Marime 0.59 kb
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#define NMAX 100000

char s [ NMAX ] , sep [ ] = "- ,!.?;" ;

int main ( )
     {

	freopen ( "text.in" , "r" , stdin ) ;
	freopen ( "text.out" , "w" , stdout ) ;

	int n = 0;

	while ( scanf ( "%c" , & s [ n ] ) != EOF ) n ++ ;

	int nr = 0 , c = 0 , si = 0 , lit = 0 ;

	for ( int i = 0 ; i <= n ; i ++ )
	    if ( isalpha ( s [ i ] ) ) {
	      if ( ! lit )
		{ si = i ; lit = 1 ; } }
	    else
		{
		   if ( si != i && lit )
		     {
			c ++ ;
			nr += ( i - si ) ;
		     }

		   lit = 0 ;

		}

	printf ( "%d" , nr / c ) ;

	return 0 ;


     }