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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:00
Consider the following declarations (1, 2, 3, 5, 7)class bagtype{public: void set(string, double, double, double, double); void print() const; string getstyle() const; double getprice() const; void get(double, double, double, double); bagtype(); bagtype(string, double, double, double, double); private: string style: double l; double w; double h; double price; }; a.) write the definition of the number function set so that private members are set according to the parametersb.) write the definition of the member function print that prints the values of the data membersc.) write the definition of the default constructor of the class bagtype so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively d.) write a c++ statement that prints the value of the object newbag.e.) write a c++ statement that declares the object tempbag of type bagtype, and initialize the member variables of tempbag to "backpack", 15, 8, 20 and 49.99, respectively
Answers: 3
question
Computers and Technology, 23.06.2019 18:00
File account.java (see previous exercise) contains a definition for a simple bank account class with methods to withdraw, deposit, get the balance and account number, and return a string representation. note that the constructor for this class creates a random account number. save this class to your directory and study it to see how it works. then write the following additional code: 1. suppose the bank wants to keep track of how many accounts exist. a. declare a private static integer variable numaccounts to hold this value. like all instance and static variables, it will be initialized (to 0, since itÒ€ℒs an int) automatically. b. add code to the constructor to increment this variable every time an account is created. c. add a static method getnumaccounts that returns the total number of accounts. think about why this method should be static - its information is not related to any particular account. d. file testaccounts1.java contains a simple program that creates the specified number of bank accounts then uses the getnumaccounts method to find how many accounts were created. save it to your directory, then use it to test your modified account class.
Answers: 3
question
Computers and Technology, 23.06.2019 23:30
What can you prevent issues related to downloading content form the internet
Answers: 1
question
Computers and Technology, 24.06.2019 14:00
Text or graphics that print at the bottom of every page are called footings footers headers headings
Answers: 1
You know the right answer?
Complete the program below by filling in code. #include
#include
#include
#inc...
Questions
question
Mathematics, 05.03.2021 22:40
question
Mathematics, 05.03.2021 22:40
question
Mathematics, 05.03.2021 22:40
question
Mathematics, 05.03.2021 22:40
Questions on the website: 13722363