Created
April 1, 2019 12:36
-
-
Save andraantariksa/e4e2ec4ab4c326e9fe6d94398e5374a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
bool is_palindrome(const std::string s){ | |
for(unsigned int i = 0; i < s.length()/2; i++){ | |
if(s[i] != s[s.length()-i-1]){ | |
return false; | |
} | |
} | |
return true; | |
} | |
int main(){ | |
std::string number; | |
std::cin>>number; | |
std::ofstream file; | |
file.open("output.txt"); | |
file<<number<<'\n'<<"is"<<((is_palindrome(number))?"":" not")<<" a palindrome number\n"; | |
file.close(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment