Question

In 1-3 sentences, describe how you would make a "Function that can test if an arbitrary...

In 1-3 sentences, describe how you would make a "Function that can test if an arbitrary string is a palindrome if stripped of punctuation", Recursively using C++

Homework Answers

Answer #1
  1. If the string has only one character, then return true.
  2. Else, if the string contains punctuation character, then remove the punctuation character.

Use ispunct() function.

int ispunct(int ch)

ch is the character to be checked. Function returns non-zero value, if ch is punctuation character otherwise zero is returned.

If non-zero value is returned, use string erase() function to remove the character.

str.erase(pos,len)

pos represents the position of the character to be removed. len represents number of characters to be removed from the pos.

3. After removing all punctuation charcters, compare first and last charcters of the substring recursively.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
In 1-3 sentences, describe how you would "Print all the odd numbers from 0 to x",...
In 1-3 sentences, describe how you would "Print all the odd numbers from 0 to x", Recursively using C++
Write an algorithm not code or solution only algorithm such as (step1, step2.....about. 1.How would you...
Write an algorithm not code or solution only algorithm such as (step1, step2.....about. 1.How would you use a stack to verify whether a given string is a palindrome or not. 2. How would you check if a string is a palindrome or not, using queues and deques.
This is for C++ A string is a palindrome if reverse of the string is same...
This is for C++ A string is a palindrome if reverse of the string is same as the original string. For example, “abba” is palindrome, but “abbc” is not palindrome. Basically a string with a plane of symmetry in the middle of it is considered a palindrome. For example, the following strings are palindromic: "abbbbba", "abba", "abbcbba", "a", etc. For this problem, you have an input string consisting of both lowercase or uppercase characters. You are allowed to pick and...
Describe in one or two sentences how (not what you would do if you knew the...
Describe in one or two sentences how (not what you would do if you knew the identity of the solution) you could experimentally identify the contents of a test tube containing one of the following two solutions using a common aqueous test solution: pb(no3)2 or kno3
Using c++ Valid Palindrome In this assignment, you need to implement a bool isPalindrome(string s) function....
Using c++ Valid Palindrome In this assignment, you need to implement a bool isPalindrome(string s) function. Given a string s, isPalindrome(s) can determine if s is a palindrome, considering only alphanumeric characters and ignoring cases. Note: for the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: ”A man, a plan, a canal: Panama” Output: true Example 2: Input: ”race a car” Output: false Requirement: There are many methods to check if a string is...
In a few sentences, describe a possible study that would require you to use a chi-square...
In a few sentences, describe a possible study that would require you to use a chi-square analysis. Be sure to describe what your variable(s) are, how they were measured (being sure to mention the scale of measurement), and what hypothesis you would be testing.
Part 3: Create compound sentences with FANBOYS. Pay attention to punctuation.    (8 marks) 1. The car...
Part 3: Create compound sentences with FANBOYS. Pay attention to punctuation.    1. The car started to swerve (and)      _________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ 2. My tea was too sweet (for) _________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ 3. Do you want to go to the movies (or)         _________________________________________________________________________________________________________________________________________________________________________________________________________________________________ 4. I love baseball (yet) __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ Part 4: Create compound sentences using Conjunctive adverbs. (8marks) Pay attention to punctuation. 5. Tony did not want to tell the truth ____________he lied to his friends. T 6. Students must put more effort in their...
1. MAKE A SOLUTION PROBLEM a) Starting with solid sucrose, C12H22O11, describe how you would prepare...
1. MAKE A SOLUTION PROBLEM a) Starting with solid sucrose, C12H22O11, describe how you would prepare 250.0 mL of 0.250 M sucrose solution. Make sure your work supports your answer. b) Describe how you would prepare 350.0 mL of 0.100 M C12H22O11 starting with 3.00 L of 1.50 M C12H22O11. Make sure your work supports your answer. 2. MAKE A SOLUTION PROBLEM a) How would you prepare 250.0 mL of 0.150 M AgNO3 solution starting with pure AgNO3? Make sure...
Part I Please TYPE out EACH answer Using two or more complete sentences, describe how you...
Part I Please TYPE out EACH answer Using two or more complete sentences, describe how you can find a vector parallel to . A boat is traveling with a velocity measured in meters per second, is described by the vector . In two or more complete sentences explain how to find the speed of the boat and the direction it is traveling in standard position.Include all of your calculations in A boat’s velocity, measured in meters per second, is described...
How many valid 3 digit numbers can you make using the digits 0, 1, 2 and...
How many valid 3 digit numbers can you make using the digits 0, 1, 2 and 3 without repeating the digits? How about with repeating?