Cod sursa(job #61460)

Utilizator ada_sAda-Mihaela Solcan ada_s Data 19 mai 2007 16:45:35
Problema Text Scor 70
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.62 kb
//infoarena046
#include <fstream>
#include <string.h>
std::ifstream f1("text.in");
std::ofstream f2("text.out");
int main()
{
	char text[255];
	long long l, lung=0, lungT=0, nrCuv=0, i;
	f1>>text;
	while (!f1.eof())
	{
		l=strlen(text);
		for (i=0; i<l; i++)
		{
	  	if ((((int)text[i]>=65)&&((int)text[i]<=90))||(((int)text[i]>=97)&&((int)text[i]<=122)))
		  	lung++;
		  else
			  if (lung>0)
  			{
	  			nrCuv++;
		  		lungT+=lung;
			  	lung=0;
  			}//if	
		}//while	
  	if (lung>0)
	  {
		  nrCuv++;
	  	lungT+=lung;
			lung=0;
	  }//if
		f1>>text;
	}//while
	f2<<(int)(lungT/nrCuv);
	f1.close();
	f2.close();
	return 0;
}//main