From 69261ac16ceb1e44ea94be1f8918688b2b5cda7a Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Tue, 12 Jan 2021 11:58:16 +0000 Subject: - Added solutions by Ulrich Rieke. --- challenge-095/ulrich-rieke/cpp/ch-1.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 challenge-095/ulrich-rieke/cpp/ch-1.cpp (limited to 'challenge-095/ulrich-rieke/cpp/ch-1.cpp') 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 +#include +#include +#include + +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 ; +} -- cgit