Maligayang pagdating sa Imhr.ca, kung saan maaari kang makakuha ng mga sagot mula sa mga eksperto. Kumuha ng mabilis at mapagkakatiwalaang mga sagot sa iyong mga tanong mula sa dedikadong komunidad ng mga propesyonal sa aming platform. Nagbibigay ang aming platform ng seamless na karanasan para sa paghahanap ng mapagkakatiwalaang sagot mula sa isang malawak na network ng mga propesyonal.

Modify the function ispalindrome of example 6-6 so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. the ispalindrome function from example 6-6 has been included below for your convenience.

Sagot :

Answer:

#include<iostream>

#include <string>

using namespace std;

bool isPalindrome(string str)

{

int length = str.length();

for (int i = 0; i < length / 2; i++)

{

if (tolower(str[i]) != tolower(str[length - 1 - i]))

{

return false;

}

}

return true;

}

int main()

{

 if (isPalindrome("Madam"))

   cout << "madam" << " is a palindrome." << endl;

 if (isPalindrome("abBa"))

   cout << "abBa" << " is a palindrome." << endl;

 if (isPalindrome("22"))

   cout << "22" << " is a palindrome." << endl;

 if (isPalindrome("67876"))

   cout << "67876" << " is a palindrome." << endl;

 if (isPalindrome("444244"))

   cout << "444244" << " is not a palindrome." << endl;

   else

   cout << "444244" << " is not a palindrome." << endl;

 

 if (isPalindrome("trYmeuemyRT"))

   cout << "trYmeuemyRT" << " is a palindrome." << endl;

 return 0;

}

Explanation: