Cod sursa(job #58468)

Utilizator SuRfEr88Lord Anak1n SuRfEr88 Data 5 mai 2007 22:09:17
Problema Text Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.45 kb
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main()
{
  char s[100];
  int i, k=0, c=0;
  FILE *f1, *f2;
  f1 = fopen("text.in","r");
  f2 = fopen("text.out","w");
  fgets(s, 100, f1);
  for(i=0;i<strlen(s);i++)
    if (isalpha(s[i])) k++;
  i=0;
  while (i<strlen(s))
  {
    if (isalpha(s[i]))
    {
      c++;
      while (isalpha(s[i])) i++;
    } else i++;
  }
  fprintf(f2, "%d", k/c);
  fclose(f2);
  return 0;
}