Cod sursa(job #172310)

Utilizator blowfishmeBlowfish Ion blowfishme Data 6 aprilie 2008 08:26:34
Problema Text Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <fstream.h>
#include <string.h>
//#include <conio.h>

int main(){
	//clrscr();
	ifstream f("text.in");
	long l=0,c=0;
	while(!f.eof()){
		char part[100];
		f>>part;
		//cout<<part<<endl;
		//continue;
		char ch=part[0];
		if( (ch>='a' && ch<='z') || (ch>='A' && ch<='Z')){
			int i,cc=0;
			for(i=1;i<strlen(part);i++) if(part[i]=='-' || part[i]=='\'') cc++;
			c+=cc+1; //cate delimit
			l+=strlen(part)-cc;
			char lch=part[strlen(part)-1];
			if(lch=='.' || lch==',' || lch==';' || lch=='?' || lch=='!' || lch==':') l--;
			//cout<<l<<", "<<c<<endl;
		}
	}
	f.close();
	ofstream g("text.out");
	g<<l/c<<"\n";
	g.close();
}