Access over 20 million homework & study documents

A palindrome is a string of characters that is the same regardless o

Content type
User Generated
Rating
Showing Page:
1/2
A palindrome is a string of characters that is the same
regardless of whether you read it forward or backward
assuming that you ignore spaces, punctuations, and case.
For example, Race car is a palindrome. So is a man, a
plan, a canal: Panama. Instead of using stacks and
queues, this time you should write a recursive function to
determine if a string is a palindrome. Use the following
function prototype: bool isPalindrome(string s);
Solution
#include #include using namespace std; #define
false 0 #define true 1 char s[100]; char sr[100]; void
InputString(); bool PalindromeTest(); void PrintMessage();
int main() { InputString(); system(\"PAUSE\");
return 0; } void InputString(int n=0) { cout<<\"Input the
string you wish to be tested\"; cin.getline(s, 100);
if(strlen(s)>n) PalindromeTest(); } bool
PalindromeTest() { bool rvalue = true; strcpy(sr,
s); strrev(sr); if(strcmp(s, sr)==0) {
rvalue=true; PrintMessage(); } else {
rvalue=false; PrintMessage(); } } void
PrintMessage(bool rvalue) { if(true == rvalue)
cout<<\"The entered string IS a palindrome\"<

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
A palindrome is a string of characters that is the same regardless of whether you read it forward or backward – assuming that you ignore spaces, punctuations, and case. For example, “Race car” is a palindrome. So is “a man, a plan, a canal: Panama”. Instead of using stacks and queues, this time you should write a recursive function to determine if a string is a palindrome. Use the following function prototype: bool isPalindrome(string s); Solution #include #include using namespac e std; #define false 0 #define true 1 char s[100]; char sr[100]; void InputString(); bool PalindromeT ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Awesome! Perfect study aid.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4