Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <fstream>
- #include <vector>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main()
- {
- vector <int> a;
- int x, y, c;
- int n = 0;
- in >> x >> y;
- while (in >> c)
- {
- a.push_back(c);
- n++;
- }
- if (a.size() == 0)
- return 0;
- else
- {
- if (n % 2 != 0)
- {
- a.insert(a.begin() + n / 2 + 1, y); // вставляем элемент "y" после среднего элемента
- a.insert(a.begin() + n / 2, x); // вставляем элемент "x" перед средним элементом
- n += 2;
- }
- for (int i = 0; i < n; i++)
- out << a[i] << ' ';
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement