Cod sursa(job #334783)

Utilizator iulia609fara nume iulia609 Data 27 iulie 2009 23:28:54
Problema Text Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include<stdio.h>
using namespace std;

int main()
{ int k, cont, ok;
  char c;
  
	  FILE *f = fopen("text.in", "r");
	  FILE *g = fopen("text.out", "w");
	  
	  fscanf(f, "%c", &c);
	  k =0, cont = 0;
	  while(c != '\n')
		  {
			  ok = 0;
			  while((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
				  {
					  k++;
					  ok = 1;
					  fscanf(f, "%c", &c);
				  }
			  if(ok) cont++;
			  fscanf(f, "%c", &c);
		  }
	  
	  fprintf(g, "%d\n", k/cont);
	  
	  fclose(f);
	  fclose(g);
	  return 0;
}