Cod sursa(job #524581)

Utilizator cioboata.iCioboata Ioan Liviu cioboata.i Data 22 ianuarie 2011 13:47:29
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include<cstdio>
//#include<cstring>
char v[]=" ,.-;:!?123456789";
//char v[20]={' ',',','.','-','!','?'};

bool comp(char x)
{
	int i;
	for(i=0;i<=16;i++)
		if(v[i]==x)
			return false;
	return true;
}

int main()
{
	freopen("text.in","r",stdin);
	freopen("text.out","w",stdout);
	int nrcuv=0,nrtxt=0;
	char a,b;
	scanf("%c",&a);
	if(comp(a))
		++nrcuv;
	while (scanf("%c",&b)!=EOF)
	{
		if(!comp(a))
		{
			if(comp(b))
			{	
				nrcuv++;
			}
		}
		if(comp(b))
			nrtxt++;
		a=b;
	}
	printf("%d ",nrtxt/nrcuv);
	//printf("%d %d",nrtxt,nrcuv);
	return 0;
}