Cod sursa(job #306832)

Utilizator diana_7Nica Lorela-Diana diana_7 Data 21 aprilie 2009 23:35:59
Problema Text Scor 60
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.53 kb
#include<iostream.h>
#include<fstream.h>
#include<string.h>
#include<ctype.h>

ifstream f("text.in");
ofstream g("text.out");

int main()
{
	long nr,sum;
	char c,a;
	nr=0;
	sum=0;
	f.get(a);
	if(isalpha(a))nr++,sum++;
	while(!f.eof())
	{
		f.get(c);
		if(isalpha(c))sum++;//,cout<<a<<" "<<c<<" "<<sum<<" sum++ \n";
		else if(isalpha(a))nr++;//,cout<<a<<" "<<c<<" "<<nr<<" nr++ \n";
		a=c;
	}
	
	if(isalpha(a))nr++,sum--;
	
	if(nr==0)g<<"0\n";
	else g<<sum/nr<<"\n";
	
	f.close();
	g.close();
	return 0;
}