C++ 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; } Enter program input - 5 10 4 39 12 2
C++
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<int>& myVec)
#include <iostream>
#include <vector>
using namespace std;
/* Define your function here */
int main() {
/* Type your code here */
return 0;
}
Enter program input - 5 10 4 39 12 2
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images