통계 단어 수 c 알고리즘

3426 단어 통계단어.
단어 수 집계-클 라 우 드 코드http://yuncode.net/code/c_50b56eff6668752
 

  
  
  
  
  1. /*   */ 
  2. #include <stdio.h>  
  3. #include <string.h>  
  4.  
  5. #define MAX_STRING 200                                  /*   */  
  6.  
  7. int main(void) {  
  8.     char str[MAX_STRING] = { 0 }; /*  str, 0 */ 
  9.     int i = 0;  
  10.     int length = 0;  
  11.     int count = 0;  
  12.  
  13.     /*   */ 
  14.     printf("Input original String:");  
  15.     gets(str); /*  str  */ 
  16.  
  17.     length = strlen(str); /*  str  */ 
  18.  
  19.     /*   */ 
  20.     for (i = 0; i < length; ++i) {  
  21.         if (str[i] != ' ') { /*   */ 
  22.             ++count;  
  23.             while (' ' != str[i] && '\0' != str[i]) /*   */ 
  24.                 ++i;  
  25.         }  
  26.     }  
  27.  
  28.     printf("There are %d words in \"%s\".
    "
    /*   */ 
  29.     count, str);  
  30.  
  31.     return 0;  

좋은 웹페이지 즐겨찾기