Cod sursa(job #167608)

Utilizator PrestafariMiron Stanciu Prestafari Data 29 martie 2008 20:36:47
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.68 kb
#include <fstream>
using namespace std;
int main ()
{
	ifstream f ("text.in", ios::in);
	ofstream g ("text.out", ios::out);	
	char text[10000];
	f.getline (text, 10000);
	int nrcuv=0, nrlit=0;
	for (int i=0; text[i]!=NULL; i++)
	{
		if ( (text[i]>='A' && text[i]<='Z') || (text[i]>='a' && text[i]<='z') )
			nrlit++;
		if ( (text[i]==' ') && ( ( (text[i-1]>='A' && text[i-1]<='Z') || (text[i-1]>='a' && text[i-1]<='z') ) || ( (text[i-2]>='A' && text[i-2]<='Z') || (text[i-2]>='a' && text[i-2]<='z') ) ) )
			nrcuv++;
		if ( (text[i]=='-') && ( ( (text[i-1]>='A' && text[i-1]<='Z') || (text[i-1]>='a' && text[i-1]<='z') ) ) )
			nrcuv++;
	}
	nrcuv++;
	g<<nrlit/nrcuv;
	return 0;
}