我进入out_of_range我的代码。我必须如何解决这个问题?有2个功能。第一个函数检查字符串是否为回文。第二个函数必须从向量中找到回文并将其复制到作为返回值的新向量。
#include "pch.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
bool IsPalindrom(string a)
{
string b = a;
reverse(a.begin(), a.end());
if (b == a)
{
cout << "success " << endl;
return true;
}
else {
cout << "error";
return false;
}
}
vector<string> PalindromFilter(vector<string> words, int minLength)
{
vector<string> pol;
for (int i = 0; i <= words.size(); ++i)
{
if (IsPalindrom(words[i]) && words[i].size() > minLength)
{
pol.at(i) = words.at(i);
}
}
return …Run Code Online (Sandbox Code Playgroud)