0

How do I solve the Palindrome C++ problem?

Palindrome

19th May 2022, 9:05 PM
Brian
2 Réponses
0
#include <iostream> using namespace std; bool isPalindrome(int x) { //complete the function } int main() { int n; cin >>n; if(isPalindrome(n)) { cout <<n<<" is a palindrome"; } else { cout << n<<" is NOT a palindrome"; } return 0; }
19th May 2022, 9:06 PM
Brian
0
One way would be to convert x into a string (use to_string(x)) and then compare characters, beginning with ending and work toward the middle.
20th May 2022, 12:03 AM
Brian
Brian - avatar