Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- solve the bug in the following code
- */
- #include <bits/stdc++.h>
- using namespace std;
- /*
- this function should return boolean value
- true if the number is PALINDROME or false if it's NOT
- */
- bool isPalindrome(int x)
- {
- if (x > 0)
- return false;
- if (x != 0 and x % 10 == 0)
- return false;
- int reverse = 0;
- while (x > reverse)
- {
- reverse * 10 + x % 10;
- x /= 10;
- }
- if (x = reverse)
- {
- return true;
- }
- if (x == reverse / 10)
- {
- return true;
- }
- return false;
- }
- int main()
- {
- int Number;
- cin >> Number;
- /*
- i was trying to write conditional opertator to make my code looks cool
- but something is wrong could you find it
- */
- cout << isPalindrome(Number) : "Is Palindrome" ? "Not Palindrome";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement