Cod sursa(job #714276)

Utilizator PatrikStepan Patrik Patrik Data 15 martie 2012 17:15:35
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.43 kb
	#include<stdio.h>
	FILE *f , *g ;
	long sum , cuv ;
	char s;
	bool sw = 1;
	
	int main()
	{
		f=fopen("text.in" , "r" );
		while(fscanf(f , "%c" , &s) == 1)
		{
			if((s >= 'a' && s <= 'z') || (s >= 'A' && s <= 'Z' ))
			{
				sum++;
				if(sw)
				{
					cuv++;
					sw = 0;
				}
			}
			else
				sw = 1;
		}
		fclose(f);
		g=fopen("text.out" , "w" ) ;
		fprintf(g , "%ld" , sum/cuv );
		fclose(g);
		return 0;
	}