1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include <iostream>
#include <vector>
using namespace std;
bool isPalindrome( vector<int> &V, int L, int R )
{
return L >= R || ( V[L] == V[R] && isPalindrome( V, L + 1, R - 1) );
}
int main()
{
vector<int> U = { 1, 3, 5, 4, 5, 3, 1 }; cout << boolalpha << isPalindrome( U, 0, U.size() - 1 ) << '\n';
vector<int> V = { 1, 3, 5, 4, 3, 5, 1 }; cout << boolalpha << isPalindrome( V, 0, V.size() - 1 ) << '\n';
}
| |