diff --git a/others/palindrome_of_number.cpp b/others/palindrome_of_number.cpp index 647803997..dda872882 100644 --- a/others/palindrome_of_number.cpp +++ b/others/palindrome_of_number.cpp @@ -1,23 +1,20 @@ -#include #include +#include -using namespace std; +int main() { + int num; + std::cout << "Enter number = "; + std::cin >> num; -int main() -{ - int num; - cout << "Enter number = "; - cin >> num; + std::string s1 = std::to_string(num); + std::string s2 = s1; - string s1 = to_string(num); - string s2 = s1; + reverse(s1.begin(), s1.end()); - reverse(s1.begin(), s1.end()); + if (s1 == s2) + std::cout << "true"; + else + std::cout << "false"; - if (s1 == s2) - cout << "true"; - else - cout << "false"; - - return 0; + return 0; }