Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Title Blank Replace Problem Given a string arguments, define the recursive function blankReplace(), which replaces all instances of the dash character -found within s with

Title Blank Replace Problem Given a string arguments, define the recursive function blankReplace(), which replaces all instances of the dash character \"-\"found within s with the blank space character \"\". As examples, a call to blankReplace(\"Test- Example\") will return the string \"Test Example\", while a call to blankReplace(\"133-Exam-1-Study-Guide\") will return \"133 Exam Study Guide\" In a given recursive call, the current substring's last character will be concatenated to a smaller instance of blankReplace(). If this last character is not a dash, then it will be concatenated to a smaller instance of blankReplace(); otherwise, a blank space will be concatenated to this smaller instance. The function's base case occurs once the smallest possible non-empty string, a single character, is returned. This function terminates by returning the complete string back to the calling function with all dashes replaced by blank spaces. Your recursive function should have a std::string return type, so you will need a way to ensure that your base case is returning a single character string literal, not a character literal. You are welcome to try to_string() to see what kinds of issues its usage string, a single character, is returned. This function terminates by returning the complete string back to the calling function with all dashes replaced by blank spaces. Your recursive function should have a std::string return type, so you will need a way to ensure that your base case is returning a single character string literal, not a character literal. You are welcome to try to_string() to see what kinds of issues its usage creates. As a courtesy, recall that character positioning in strings is zero-based. Implementation Your definition must adhere to the following requirements: blankReplace() correctly, recursively returns the string arguments with each dash character \"-\" replaced with the blank space character\". (4 points) Characters must be added to the a recursively-returned string using the addition operator (+) or equivalent. Characters must be added to the a recursively-returned string using the addition operator ( + ) or equivalent. (2 points) Your recursive definition must not use any loops (e.g. for loops, while loops, do-while loops, ranged for loops, etc.), under any circumstances. (2 points) Results To verify your work, you are provided with the following main() function: int main() cout cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

Students also viewed these Programming questions