Answered step by step
Verified Expert Solution
Link Copied!

Question

...
1 Approved Answer

write a Sort a vector Define a function named SortVector that takes a vector of integers as a parameter. Function SortVector() modifies the vector parameter

write a Sort a vector

Define a function named SortVector that takes a vector of integers as a parameter. Function SortVector() modifies the vector parameter by sorting the elements in descending order (highest to lowest). Then write a main program that reads a list of integers from input, stores the integers in a vector, calls SortVector(), and outputs the sorted vector. The first input integer indicates how many numbers are in the list.

Ex: If the input is:

5 10 4 39 12 2 

the output is:

39,12,10,4,2, 

For coding simplicity, follow every output value by a comma, including the last one.

Your program must define and call the following function: void SortVector(vector& myVec)

#include #include using namespace std;

/* Define your function here */

int main() {

/* Type your code here */

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Algorithms

Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest

3rd edition

978-0262033848

More Books

Students also viewed these Algorithms questions