Advertisement
Guest User

Szószámlálás

a guest
Feb 26th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6.  
  7. char s[50],ch;
  8. int i,c=0,len;
  9.  
  10.  
  11.  
  12. while ( gets(s) ){
  13.  
  14. len = strlen(s);
  15.  
  16. if ( len == 0 ) break;
  17.  
  18.  
  19. c=0;
  20.  
  21. for(i=0; s[i]!='\0' ; i++ ){
  22.  
  23. if(s[i]==' '){
  24.  
  25. c++;
  26.  
  27. while(s[i]==' ')
  28.  
  29. i++;
  30. }
  31. }
  32.  
  33. printf("%d\n",c+1);
  34. }
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement