Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <ctime>
- #include <algorithm>
- using namespace std;
- int main() {
- vector <int> arr;
- int n, a, k1, k2;
- cin >> n;
- for (int i = 0; i < n; ++i) { // я считываю вручную, но можно заменить на ранд
- cin >> a;
- arr.push_back(a);
- }
- cin >> k1 >> k2;
- if (k1 < 0 || k2 >= n) {
- for (auto x : arr)
- cout << x << " ";
- return 0;
- }
- for (int i = k2; i >= k1; max(i--, 0)){ // тут я удаляю элементы с конца, а не сначала, потому что если их удалять сначала, то индексация ломается
- arr.erase(arr.begin() + i);
- }
- for (auto x : arr)
- cout << x << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement