TheAlgorithms/C++
1.0.0
All the algorithms implemented in C++
Loading...
Searching...
No Matches
palindrome_of_number.cpp
Go to the documentation of this file.
1
8
#include <algorithm>
9
#include <iostream>
10
11
#ifdef _MSC_VER
12
// Required to compile std::toString function using MSVC
13
#include <string>
14
#else
15
#include <cstring>
16
#endif
17
19
int
main
() {
20
int
num;
21
std::cout <<
"Enter number = "
;
22
std::cin >> num;
23
24
std::string s1 = std::to_string(num);
// convert number to string
25
std::string s2 = s1;
26
27
std::reverse(s1.begin(), s1.end());
// reverse the string
28
29
if
(s1 == s2)
// check if reverse and original string are identical
30
std::cout <<
"true"
;
31
else
32
std::cout <<
"false"
;
33
34
return
0;
35
}
main
int main()
Definition
palindrome_of_number.cpp:19
others
palindrome_of_number.cpp
Generated by
1.12.0