0
My Code in C doesn't work at average word length challenge
#include <stdio.h> int main() { char ar[50]; fgets(ar,50,stdin); int i,spaces=0,letters=0; for(i=0;ar[i]!='\0';i++){ if((ar[i]<=122 && ar[i]>=97)||(ar[i]<=90 && ar[i]>=65)){ letters++; } if(ar[i]==' '){ spaces++; } } int div=letters/(spaces+1); if(letters%(spaces+1)==0){ printf("%d",div); } else if(letters%(spaces+1)>0){ printf("%d",div+1); } return 0; } This code doesn't work in Average Word Length Challenge but why? It fails at 5ᵗʰ case.
1 Respuesta
+ 1
The length of the 5th test case is greater than 50. Use "char ar[70];" and "fgets(ar,70,stdin);", for example.