Cod sursa(job #1160170)

Utilizator vladradu2014Radu Vlad Alexandru vladradu2014 Data 30 martie 2014 12:32:39
Problema Text Scor 0
Compilator c Status done
Runda Arhiva de probleme Marime 0.79 kb
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <string.h>

int count(char string[])
{
  int wlength=0;
  int nwords=0;
  int inword=0;
  int length=strlen(string);    
  int i;
  printf("%s",string);
  
  for(i=0;i<length;i++)
  {
      if(isalpha(string[i]))
      {
              inword=1;
              ++wlength;
              if(i==length-1)
                  ++nwords;
      }
      else
      {
          if(inword)
          {
              ++nwords;
              inword=0;
          }
      }
  } 

 return wlength/nwords;
}


int main()
{
  char string[100000];
   
  freopen("text.in","r",stdin);
  freopen("text.out","w",stdout);
  
  scanf("%s",string);

  int nwords=count(string);
  
  printf("%d",nwords);
   
   return 0;
}