Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <vector>
- using namespace std;
- // определяет, будет ли строка s палиндромом
- bool IsPalindrome(string s) {
- for (int i = 0; i < s.size() / 2; ++i) {
- if (s[i] != s[s.size() - i - 1]) {
- return false;
- }
- }
- return true;
- }
- vector<string> PalindromeFilter(vector<string> words, int min_length) {
- vector<string>search_words;
- for (const auto&word: words) {
- if (IsPalindrome(word) && word.size() >= min_length) {
- search_words.push_back(word);
- }
- }
- return search_words;
- }
- int main() {
- vector<string>words{"rotor", "anna", "kayak"};
- auto x = PalindromeFilter(words, 5);
- for (const auto& l : x) {
- std::cout << l << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement