Page 1 of 1

Let's say that a "pair" in a string is two instances of a char separated by a char. So in "AXA" the A's make a pair. Pai

Posted: Wed Apr 27, 2022 3:30 pm
by answerhappygod
Let S Say That A Pair In A String Is Two Instances Of A Char Separated By A Char So In Axa The A S Make A Pair Pai 1
Let S Say That A Pair In A String Is Two Instances Of A Char Separated By A Char So In Axa The A S Make A Pair Pai 1 (91.99 KiB) Viewed 47 times
Let's say that a "pair" in a string is two instances of a char separated by a char. So in "AXA" the A's make a pair. Pair's can overlap, so "AxAxA" contains 3 pairs -- 2 for A and 1 for x. Complete the function below to recursively compute the number of pairs in the given string: int countPairs (char *str) { } Test your function with the following strings. String Correct # of pairs "axa" || 1 "axax" 2 "axbx" || 1 "hi" 10 ["hihih" ||3 1111 "ihihhh"||3 NO 0 Il 11 a "aa" 0 "aaa" | 1 The recursive algorithm should not use any global variables.