Skip to content

Instantly share code, notes, and snippets.

@indrasaputra
Created August 24, 2015 11:38
Show Gist options
  • Save indrasaputra/4c043933ecb573dd6c5f to your computer and use it in GitHub Desktop.
Save indrasaputra/4c043933ecb573dd6c5f to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#define fi first
#define sc second
#define MOD7 1000000007
#define MAX_SIEVE 1000001
#define MAX_INT 2000000001
using namespace std;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
bool isPalindrome(char* sentence)
{
int length = strlen(sentence);
for(int i=0; i<length/2; i++)
{
if(sentence[i] != sentence[length-i-1])
{
return false;
}
}
return true;
}
int main()
{
char sentence1[50] = "indrasaputrartupasardni";
char sentence2[50] = "thisisnotapalindrome";
printf("%s\n", isPalindrome(sentence1) ? "Palindrome" : "Not a Palindrome");
printf("%s\n", isPalindrome(sentence2) ? "Palindrome" : "Not a Palindrome");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment