Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Biggest even palindrom
//Title of this code #include <iostream> using namespace std; bool isPalindrom(const string& s, int i, int j) { while (i < j) { if (s[i] != s[j]) return false; ++i; --j; } return true; } inline bool even(int n) { if (n & 1) return false; return true; } int biggestEvenPalindrom(const string& s) { int biggest = 0; for (int i = 0; i < s.length(); ++i) for (int j = s.length() - 1; j > i; --j) if (even(j - i + 1) && (j - i + 1 > biggest) && isPalindrom(s, i, j)) { biggest = j - i + 1; } return biggest; } int main() { cout << biggestEvenPalindrom("AABBcAADcAAc"); }
run
|
edit
|
history
|
help
0
integerDivision
Полиморфизм. Простейшее ДЕМО.
pangram
Binary search2
cppPyFoodVatTip
Cotton Farm 0.0.1.0
as
Fibonacci
Count edges in a graph
Test 12(2021)