Cod sursa(job #132260)

Utilizator soriynSorin Rita soriyn Data 5 februarie 2008 15:37:20
Problema Text Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.61 kb
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main()
{  
    FILE *i;
    FILE *o;
    int cuv,lit,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));
    if (c == EOF) break;	
    cuv = cuv + 1;	
    
    do c = fgetc(i); while (!isspace(c) && c != EOF && c!='-');
    
  } 
  while (c != EOF);
  
  med=lit/cuv;
 o=fopen("texr.out","w");
 fprintf(o,"%d",med);
 return 0;
}