saintegg
#include <iostream>#include <vector> int main (){ std::vector <int> mas; int n; std::cout << "Set n: "; std::cin >> n; std::cout << "Set elements: "; for (int i = 0; i < n; i++) { int a; std::cin >> a; mas.push_back(a); } std::cout << "Set k and m: "; int k, m; std::cin >> k >> m; mas.erase(mas.begin() + k -1, mas.begin() + m); for (int i = 0; i < mas.size(); i++) { std::cout << mas[i] << " "; } }
Answers & Comments
int main (){ std::vector <int> mas; int n; std::cout << "Set n: "; std::cin >> n; std::cout << "Set elements: "; for (int i = 0; i < n; i++) { int a; std::cin >> a; mas.push_back(a); } std::cout << "Set k and m: "; int k, m; std::cin >> k >> m; mas.erase(mas.begin() + k -1, mas.begin() + m); for (int i = 0; i < mas.size(); i++) { std::cout << mas[i] << " "; } }