#include <iostream>
#include <string>
#include <cctype>
using namespace std;
signed main() {
string line, buff = "";
bool isPalindrome = true;
getline(cin, line);
for (int i = 0; i < line.size(); i++) {
if (isalnum(line[i]))
buff += line[i];
}
for (int i = 0; i < buff.size() / 2; ++i)
{
if (buff[i] != buff[buff.size() - i - 1])
{
isPalindrome = false;
break;
}
}
if (isPalindrome)
cout << "TRUE";
else
cout << "FALSE";
return 0;
}
Решение в лоб:
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> a(10);
cout << "Enter array:" <<endl;
for (int& i : a) {
cin >> i;
}
int m = 0;
for (int i = 0; i < a.size(); ++i) {
if (a[i] > 0) {
m = i + 1;
}
}
cout << "Enter element to insert:" << endl;
int v;
cin >> v;
a.insert(a.begin() + m, v);
cout << "Result is below:" << endl;
for(const int& i : a) {
cout << i << ' ';
}
cout << endl;
return 0;
}