Advertisement
zsoltizbekk

mondatzaro

Apr 13th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5.  
  6. int punctuation( char *s )
  7. {
  8.   int i,
  9.   szamlalo = 0,
  10.   hossz = strlen(s);
  11.  
  12.   for(i = 1; i < hossz; i++)
  13.   {
  14.         if( (s[i] == '.' || s[i] == '!' || s[i] == '?') && (isalpha(s[i-1])) )
  15.         {
  16.             while(s[i] == '.' || s[i] == '!' || s[i] == '?')
  17.                 i++;
  18.             if(s[i] == ' ' || s[i] == '\0')
  19.                 szamlalo++;
  20.         }
  21.   }
  22.   return szamlalo;
  23. }
  24.  
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. int main()
  28. {
  29.   char line[ 1000 ];
  30.   int punctuation( char * );
  31.   while ( gets( line ) != NULL )
  32.     printf( "%d\n", punctuation( line ) );
  33.   return EXIT_SUCCESS;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement