Cod sursa(job #819482)

Utilizator Al3ks1002Alex Cociorva Al3ks1002 Data 19 noiembrie 2012 09:36:45
Problema Text Scor 40
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include<stdio.h>
#include<string.h>
char s[1100000],x;
int w,ok,i,cnt,cnt2;
int main()
{
	freopen("text.in","r",stdin);
	freopen("text.out","w",stdout);
	while(scanf("%c",&x)+1)
	{
		if((x>='a'&&x<='z')||(x>='A'&&x<='Z')) {s[++w]=x;ok=1;}
		if(x==' '&&ok) {s[++w]=' ';ok=0;}
	}
	s[++w]=' ';
	for(i=1;i<=w;i++)
	{
		x=s[i];
		if((x>='a'&&x<='z')||(x>='A'&&x<='Z')) cnt++;
		if(x==' ') cnt2++;
	}
	cnt2++;
	printf("%d\n",cnt/cnt2);
	return 0;
}