Advertisement
Pafnytiu

Практика 1 - а

Jul 4th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <iostream> // Для использования функции cout
  2. #include <cstdlib> // Для использования функции atoi
  3. #include <vector> // Для использования класса вектор STL
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. setlocale(0,"");
  10. vector<int> iVec;
  11. int n, q,x,y;
  12. cout << "Введите x: ";
  13. cin >> x;
  14. cout << "Введите y: ";
  15. cin >> y;
  16. cout << "Введите размерность n: ";
  17. cin >> n;
  18. for (int i = 0; i < n; i++)
  19. {
  20. cout << "Введите элемент " << i << " - ";
  21. cin >> q;
  22. iVec.push_back(q);
  23. }
  24. iVec.insert(iVec.begin()+((n/2)+1), y);
  25. iVec.insert(iVec.begin()+((n/2)), x);
  26. for (vector <int>::iterator iter = iVec.begin(); iter < iVec.end(); iter++)
  27. cout << *iter << endl;
  28. system("pause");
  29. return(0);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement