palindrome
-
문자 - 펠린드롬(Palindrome) 인지 확인 하기기본(Basic) 2021. 1. 6. 12:47
include #include // 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..
-
숫자 - 펠린드롬(Palindrome) 인지 확인 하기기본(Basic) 2021. 1. 6. 12:46
#include #include #include #include #include #include #include #include #include //#include #include #include #include #define MAX_SIZE 100 #define INF 0x7fffffff using namespace std; int dx[4] = {1, -1, 0, 0}; int dy[4] = {0, 0, -1, 1}; int reverse(int x) { int rev = 0; while(x != 0){ rev = rev*10 + x%10; x = x/10; } return rev; } int main() { int n; cin >> n; if (n == reverse(n)) { cout