subject

Complete the program below by filling in code. #include
#include
#include
#include
using namespace std;

void print(const string& title, const vector& v)
{
cout << title << " ";
for (int i = 0; i < v. size(); i++)
cout << v[i] << " ";
cout << endl;
}

int main()
{
vector v;
for (int i = 0; i < 5; i++)
v. push_back(i);

FILL_CODE
FILL_CODE

print("The elements in vector:", v);

sort(v. begin(), v. end()); // Sort the elements in v
print("Sorted elements:", v);

random_shuffle(v. begin(), v. end()); // Shuffle the elements in v
print("After random shuffle:", v);

cout << "The max element is " <<
*max_element(v. begin(), v. end()) << endl;

cout << "The min element is " <<
*min_element(v. begin(), v. end()) << endl;

int key = 45;
if (find(v. begin(), v. end(), key) == v. end())
cout << key << " is not in the vector" << endl;
else
cout << key << " is in the vector" << endl;

return 0;
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 20:00, ayoismeisalex
When you mouse over and click to add a search term this(these) boolean operator(s) is(are) not implied. (select all that apply)?
Answers: 1
image
Computers and Technology, 23.06.2019 01:30, solikhalifeoy3j1r
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
image
Computers and Technology, 23.06.2019 14:30, soapai
Select the correct answer. sean is a computer programmer. he has programmed an application for toddlers that plays nursery rhymes. however, a logic error has occurred in the program. which problem is a likely consequence of the error? a. the program crashes every time the user wants to play the nursery rhymes. b. the program crosses its buffer boundaries and overwrites an adjacent program. c. the program plays a different nursery rhyme than the one the user intended to play. d. the program shows different structures in its programming language code. e. the program introduces new viruses every time the user plays a nursery rhyme.
Answers: 1
image
Computers and Technology, 23.06.2019 22:30, reaganphelps3
What would be the address of the cell, which is at the intersection of the second row and the third column in a worksheet?
Answers: 1
You know the right answer?
Complete the program below by filling in code. #include
#include
#include
#inc...

Questions in other subjects:

Konu
English, 04.07.2019 05:30
Konu
Mathematics, 04.07.2019 05:30
Konu
Mathematics, 04.07.2019 05:30