-
문자 - 펠린드롬(Palindrome) 인지 확인 하기기본(Basic) 2021. 1. 6. 12:47반응형
include <stdio.h> #include <string.h> // A function to check if a string str is palindrome void isPalindrome(char str[]) { // Start from leftmost and rightmost corners of str int l = 0; int h = strlen(str) - 1; // Keep comparing characters while they are same while (h > l) { if (str[l++] != str[h--]) { printf("%s is Not Palindrome", str); return; } } printf("%s is palindrome", str); } // Driver program to test above function int main() { isPalindrome("abba"); isPalindrome("abbccbba"); isPalindrome("geeks"); return 0; }
반응형'기본(Basic)' 카테고리의 다른 글
PermCheck (0) 2021.01.06 숫자 - 펠린드롬(Palindrome) 인지 확인 하기 (0) 2021.01.06 순열 출력하기 (0) 2021.01.06 정수 - 수를 처리하는 방법 (0) 2021.01.06 정수 - 수를 처리하는 방법 (0) 2021.01.06