Last active
June 26, 2021 04:11
-
-
Save emadflash/20049ecef2889bcf69f784258f3cde3c to your computer and use it in GitHub Desktop.
fykin pallindromes
This file contains hidden or 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<stdio.h> | |
#include<string.h> | |
#include<stdbool.h> | |
int is_pallindrome(char* string, size_t len) { | |
char* begin = string; | |
char* end = string + len - 1; | |
int checking = len / 2; | |
while(end != begin && checking-- != 0) { | |
if (*end != *begin) { | |
return -1; | |
} | |
end--; | |
begin++; | |
} | |
return 0; | |
} | |
int main() { | |
char* string = "ieaeaaei"; | |
if (is_pallindrome(string, strlen(string)) < 0) { | |
printf("not pallindrome"); | |
} else { | |
printf("pallindrome"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment