-
-
Save kehanlu/e99658e17ad7b2aca95a6ee88efb82ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "stdio.h" | |
| #include "string.h" | |
| int main(){ | |
| char a[1000]; | |
| while(fgets(a,1000,stdin)!=NULL){ | |
| int space=0; | |
| int letter =0; | |
| if(a[0]==' ') | |
| space--; | |
| for(int i=0;i<strlen(a);i++){ | |
| if(a[i]==' '){ | |
| space++; | |
| }else{ | |
| letter++; | |
| } | |
| } | |
| double output = (double)(letter-1)/(space+1); | |
| printf("Average word length: %.1f\n",output); | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment