aboutsummaryrefslogtreecommitdiff
path: root/challenge-095/ulrich-rieke/cpp/ch-1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-095/ulrich-rieke/cpp/ch-1.cpp')
-rw-r--r--challenge-095/ulrich-rieke/cpp/ch-1.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/challenge-095/ulrich-rieke/cpp/ch-1.cpp b/challenge-095/ulrich-rieke/cpp/ch-1.cpp
new file mode 100644
index 0000000000..2e6417d643
--- /dev/null
+++ b/challenge-095/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,20 @@
+#include <algorithm>
+#include <string>
+#include <iostream>
+#include <cstdlib>
+
+bool isPalindrome( int n ) {
+ std::string numstring { std::to_string( n ) } ;
+ std::string original( numstring ) ;
+ std::reverse( numstring.begin( ) , numstring.end( ) ) ;
+ return original == numstring ;
+}
+
+int main( int argc , char * argv[ ] ) {
+ if ( isPalindrome( std::atoi( argv[1] ) ))
+ std::cout << 1 ;
+ else
+ std::cout << 0 ;
+ std::cout << std::endl ;
+ return 0 ;
+}