Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <list>
- #include <fstream>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main() {
- int value;
- int n;
- cin >> n;
- vector<int> a;
- list<int> b;
- for (int i = 0; i < n; i++)
- {
- cin >> value;
- a.push_back(value);
- b.push_back(value);
- }
- int x, y;
- cin >> x >> y;
- list<int>::iterator iter;
- iter = b.begin();
- for (int i = 1; i < b.size() / 2 + 1; i++) {
- iter++;
- }
- b.insert(iter, x);
- iter++;
- b.insert(iter, y);
- for (iter = b.begin(); iter != b.end(); iter++) {
- cout << *iter << " ";
- }
- cout << endl;
- a[0] = a[0] - 1;
- a[1] = a[1] - 1;
- a[a.size() - 1] = a[a.size() - 1] - 1;
- a[a.size() - 2] = a[a.size() - 2] - 1;
- for (auto it = a.begin(); it != a.end(); it++) {
- cout << *it << " ";
- }
- return 0;
- }
- 5
- 1 2 3 4 5
- 6 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement