Skip to content

Instantly share code, notes, and snippets.

@kyagrd
Created October 22, 2018 02:38
Show Gist options
  • Save kyagrd/357c0294da18894df7da05648561618c to your computer and use it in GitHub Desktop.
Save kyagrd/357c0294da18894df7da05648561618c to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdbool.h>
size_t strlen(const char* str)
{
size_t n = 0;
while (str[n]) ++n;
return n;
}
int main()
{
char str[128];
scanf("%s", str);
int n = strlen(str);
for (int j = n-1; j>=0; --j)
printf("%c",str[j]);
printf("\n");
_Bool pal = true;
int i = 0;
int j = n;
while (i <= j)
{
if (str[i++] != str[--j])
{
pal = false;
break;
}
}
if (pal) printf("palindrome\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment