Advertisement
Guest User

mafhid

a guest
Jan 16th, 2018
105
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. #define MAX_LENGTH 100
  3. int num_special_points (char *s, int i);
  4. int main()
  5. {
  6.  char s[MAX_LENGTH];
  7.  scanf("%s", s);
  8.  printf("The number of special points is %d.", num_special_points(s,0));
  9.  return 0;
  10. }
  11. int num_special_points (char *s, int i)
  12. {/*start of num_special points*/
  13.     int ctr=0;
  14.     if((*(s+2)=='\0'))/*end of string*/
  15.     {/*start of if*/
  16.         return ctr;
  17.     }/*end of if*/
  18.     ctr+=num_special_points(s+1,++i);
  19.     if((*(s+1)-*s)*(*(s+1)-*(s+2))>0 && i%(int)(*(s+1)-'0')==0)/*special point*/
  20.     {/*start of if*/
  21.         return ++ctr;
  22.     }/*end of if*/
  23.     return ctr;
  24. }/*end of num_special points*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement