#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int palindrome(string arr,int start,int end) {
if (start >= end)
return 0;
else if (arr[start] == arr[end])
return palindrome(arr, start + 1, end - 1);
else
return 1;
}
int main() {
string arr;
arr = "level";
int res;
res = palindrome(arr, 0, arr.size() - 1);
cout << res;
}
'C++' 카테고리의 다른 글
[C++] DFS(깊이 우선 탐색) 알고리즘 코드 구현 (0) | 2020.08.11 |
---|---|
[C++] 이진탐색 구현 (0) | 2020.08.07 |
[C++] 재귀호출로 배열의 합 구하기 (0) | 2020.08.05 |
[C++] 재귀호출로 팩토리얼 구하기 (0) | 2020.08.05 |
[C++] 삽입정렬 코드 구현 (0) | 2020.08.04 |