Cod sursa(job #132396)

Utilizator soriynSorin Rita soriyn Data 5 februarie 2008 19:20:38
Problema Text Scor 70
Compilator c Status done
Runda Arhiva de probleme Marime 0.65 kb

  #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main()
{  
    FILE *i;
    FILE *o;
    int cuv=0,lit=0,c,med;
    char n;
i=fopen("text.in","r");

do{
    while(n!=EOF)
     {
         n=fgetc(i);
         if(isalpha(n))
         lit++;
         }
  }
  while(n!=EOF);
  fclose(i);
i=fopen("text.in","r");

do {
    do c = fgetc(i); while (isspace(c)&&c!='-');
    if (c == EOF) break;	
    cuv = cuv + 1;	
    
    do c = fgetc(i); while (!isspace(c) && c != EOF);
    
  } 
  while (c != EOF);
  
  med=lit/cuv;
 o=fopen("text.out","w");
 fprintf(o,"%d",med);
 fclose(i);
 fclose(o);
 return 0;
}