1. Engineering
  2. Computer Science
  3. c question...

Question: c question...

Question details

C++

Question

Use the following file Tester.cpp #include (vector> #include くiostream» using namespace std; void exchangesl(vector<int>&); void print(vector<int > v for (int i- 0; i < v.size(); i++) if (i == 0) cout << [; else cout << , ; cout < v[i]; cout << ] << endl; main() vector<int〉 a = { 1, 9, -1, 4, -1, 6, 11, 8 }; exchangesl(a); print (a); cout Expected 1, 9, 1, 4, 11, 6, 1, 81 endl: vector<int> b-t 1, 9, -1, 4, 1, 6, 11, 8, 9, -1 exchangesl(b); print(b); cout くく Expected: [1, 9, -1, 4. -1, 6. -1, 8, 9, 111 << endl; vector<int> c-1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1 ; exchangesl(c); print(c); cout Expected [1, 2, 3, 4, 1, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 5] << endl;

#include <vector> using namespace std; are exchanged. You may assume that there is at least one element. If the largest value occurs more than once, exchange the first instance. If the smallest value occurs more than once, exchange the last instance void exchangesl(vector<int>& a

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution