TheAlgorithms-C-Plus-Plus/others/palindrome_of_number.cpp
Krishna Vedala a15b5c5a9b
MSVC does not know cstring-use string-for toString
(cherry picked from commit fe9d2b9bc6)
2020-05-26 10:17:59 -04:00

28 lines
457 B
C++

#include <algorithm>
#include <iostream>
#ifdef _MSC_VER
// Required to compile std::toString function using MSVC
#include <string>
#else
#include <cstring>
#endif
int main() {
int num;
std::cout << "Enter number = ";
std::cin >> num;
std::string s1 = std::to_string(num);
std::string s2 = s1;
reverse(s1.begin(), s1.end());
if (s1 == s2)
std::cout << "true";
else
std::cout << "false";
return 0;
}