IDNStudy.com, ang iyong mapagkukunan para sa malinaw at mabilis na mga sagot. Hanapin ang mga solusyong kailangan mo nang mabilis at tiyak sa tulong ng aming mga bihasang miyembro.
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: