Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAX_LENGTH 100
- int num_special_points (char *s, int i);
- int main()
- {
- char s[MAX_LENGTH];
- scanf("%s", s);
- printf("The number of special points is %d.", num_special_points(s,0));
- return 0;
- }
- int num_special_points (char *s, int i)
- {/*start of num_special points*/
- int ctr=0;
- if((*(s+2)=='\0'))/*end of string*/
- {/*start of if*/
- return ctr;
- }/*end of if*/
- ctr+=num_special_points(s+1,++i);
- if((*(s+1)-*s)*(*(s+1)-*(s+2))>0 && i%(int)(*(s+1)-'0')==0)/*special point*/
- {/*start of if*/
- return ++ctr;
- }/*end of if*/
- return ctr;
- }/*end of num_special points*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement