Created
October 22, 2018 02:38
-
-
Save kyagrd/357c0294da18894df7da05648561618c to your computer and use it in GitHub Desktop.
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 <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