Cod sursa(job #260856)

Utilizator ooctavTuchila Octavian ooctav Data 17 februarie 2009 16:59:12
Problema Text Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
// Text.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <stdlib.h>
int main()
{
	int n,i,c=0,d=0,l=0;
	bool s=false,a;
	char character,p=0;
	FILE *f1,*f2;
	f1=fopen("text.in","r");
	f2=fopen("text.out","w");
	do
	{
		fscanf(f1,"%c",&character);
		a=s;
		s=false;
		if(character<=90)
			if(character>=65)
			{
				c++;
				s=true;
			}
		if(character>=97)
			if(character<=122)
			{
				c++;
				s=true;
			}
		if(s==false && a==true)
			d++;
		if(character==p)
		{
			if(s==true)
				d++;
			l++;
			if(l==30)
				break;
		}
		else
			l=0;
		p=character;

	}
	while(character!='EOF' || character!=0 );
	fprintf(f2,"%d",c/d);
	fclose(f1);
	fclose(f2);

	return 0;
}