Cod sursa(job #1312892)

Utilizator savigunFeleaga Dragos-George savigun Data 10 ianuarie 2015 01:26:03
Problema Text Scor 100
Compilator c Status done
Runda Arhiva de probleme Marime 0.62 kb
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	FILE *f, *g;
	if((f=fopen("text.in", "rt"))==NULL)
		return -1;
	if((g=fopen("text.out", "wt"))==NULL)
		return -1;
	int l, i, c=0, p=0, o=0;
	char s,q;
	fseek(f, 0, SEEK_END);
	l=ftell(f);
	fseek(f, 0,0);
	fread(&q,sizeof(char),1,f);
	fread(&s,sizeof(char),1,f);
	for(i=1;i<l;i++)
		{
			if((s<'a' ||  s>'z') && (s<'A' ||  s>'Z'))
				if((q>='a' &&  q<='z') || (q>='A' && q<='Z'))
					{
						c++;
						p++;
					}
				else
					p++;
			q=s;
			fread(&s,sizeof(char),1,f);
		}		
	if(c)	
		o=(l-p)/c;
	fprintf(g,"%d",o);
	fclose(f);
	fclose(g);
	return 0;
}