Cod sursa(job #31198)

Utilizator c_e_manuEmanuel Cinca c_e_manu Data 15 martie 2007 17:22:21
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.5 kb
#include<fstream.h>
#include<iomanip.h>
#include<iostream.h>

int main()
{	ifstream f("text.in",ios::in);
	ofstream g("text.out");
	int k_cuv=0,k_lit=0;
	char c,aux='0';
	while(!f.eof())
	{	f>>resetiosflags(ios::skipws)>>c;
		if((((((c!='-'&&c!='!')&&c!='?')&&c!='.')&&c!=',')&&c!=';')&&c!=':')
		{	if(c==' ') k_cuv++;
			else	if(aux=='-') {k_cuv++;k_lit++;}
				else k_lit++;
		}
		if(c=='-') aux=c;
		else aux='0';
	}
	if(k_cuv!=0)
		g<<k_lit/k_cuv;
	else g<<0;
	f.close();
	g.close();
}