CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Created by Reynolds Onyango
// Edited for a question:
// https://www.sololearn.com/Discuss/2921745/?ref=app
// How to check whether a std::vector contains a sequence of palindromic values
#include <iostream>
#include <vector>
// forward declaration of pallindrome()
template<typename T>
bool pallindrome( const std::vector<T>& );
int main()
{
std::vector<int> C { 1, 2, 3, 2, 1 };
for( auto& it : C )
{
std::cout << it << '\t';
}
std::cout << "\nPalindrome status: "
<< std::boolalpha << pallindrome<int>( C ) << "\n";
return 0;
}
template<typename T>
bool pallindrome( const std::vector<T>& A )
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run