Skip to content

Instantly share code, notes, and snippets.

@andraantariksa
Created April 1, 2019 12:36
Show Gist options
  • Save andraantariksa/e4e2ec4ab4c326e9fe6d94398e5374a0 to your computer and use it in GitHub Desktop.
Save andraantariksa/e4e2ec4ab4c326e9fe6d94398e5374a0 to your computer and use it in GitHub Desktop.
#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