Решение в лоб:
#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;
Решение в лоб:
#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;
}