Write a recursive C++ function "accept" that takes a string and returns true if and only if it follows the a"Xb“ pattern. You can use the following main function to test "accept":

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question

Write a C++ function "accept" that takes a string and returns true if and only if it follows the ? pattern. use stacks to build the function

Write a recursive C++ function "accept" that takes a string and returns true if and only if it
follows the a"Xb"
pattern. You can use the following main function to test "accept":
int main(){
string input;
cout << "Write the string you want me to check. If you want to abort, type \"abort!\" \n";
cin >> input;
while (input!="abort!"){
if (accept(input))
cout << "follows the pattern.In";
else
cout << "does not follow the pattern.\n";
cout << "Input string: \n";
cin >> input;
}
Transcribed Image Text:Write a recursive C++ function "accept" that takes a string and returns true if and only if it follows the a"Xb" pattern. You can use the following main function to test "accept": int main(){ string input; cout << "Write the string you want me to check. If you want to abort, type \"abort!\" \n"; cin >> input; while (input!="abort!"){ if (accept(input)) cout << "follows the pattern.In"; else cout << "does not follow the pattern.\n"; cout << "Input string: \n"; cin >> input; }
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning