Cod sursa(job #1853087)

Utilizator andrei_diaconu11Andrei C. Diaconu andrei_diaconu11 Data 21 ianuarie 2017 13:52:31
Problema Text Scor 100
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.46 kb
#include <stdio.h>
#include <ctype.h>

int main()
{
  FILE *fi=fopen("text.in", "r"), *fo=fopen("text.out", "w");
  char ch, pre;
  int nrcuv=0, nrl=0;
  ch=fgetc(fi);
  if(isalpha(ch)!=0)
    nrl++;
  pre=ch;
  ch=fgetc(fi);
  while(ch!=EOF){
    if(isalpha(pre) && !isalpha(ch))
      nrcuv++;
    if(isalpha(ch))
      nrl++;
    pre=ch;
    ch=fgetc(fi);
  }
  if(isalpha(pre))
    nrcuv++;
  fprintf(fo, "%d", nrl/nrcuv);
  fclose(fi);
  fclose(fo);
  return 0;
}