For sorting a vector in the assignment below, use the simplest to code - bubble sort: https://en.wikipedia.org/wiki/Bubble_sort. Do Not Delete Any Existing Comments code underneath / where indicated. Any code submitted with comments missing, will not be graded for style and formatting. Do Not Delete Any Existing Starter Code unless directed by the instructions. Code to the given assignment, don't change the assignment to fit your code. 6.24 LAB - 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. Create a second function which sums the values stored in the 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,67 For coding simplicity, follow every output value by a comma, excluding the sum. Your program must define and call the following functions: void SortVector(vector& myVec) int SumVector(vector& myVec) Do Not Delete Any Existing Comments code underneath / where indicated. Any code submitted with comments missing, will not be graded for style and formatting. Do Not Delete Any Existing Starter Code unless directed by the instructions. Code to the given assignment, don't change the assignment to fit your code. #include #include using namespace std; /* Define your function here */ int main() { /* Type your code here */ return 0; }
For sorting a
Do Not Delete Any Existing Comments code underneath / where indicated. Any code submitted with comments missing, will not be graded for style and formatting.
Do Not Delete Any Existing Starter Code unless directed by the instructions. Code to the given assignment, don't change the assignment to fit your code.
6.24 LAB - 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. Create a second function which sums the values stored in the vector.
The first input integer indicates how many numbers are in the list.
Ex: If the input is:
5 10 4 39 12 2the output is:
39,12,10,4,2,67For coding simplicity, follow every output value by a comma, excluding the sum.
Your program must define and call the following functions:
void SortVector(vector<int>& myVec)
int SumVector(vector<int>& myVec)
Do Not Delete Any Existing Comments code underneath / where indicated. Any code submitted with comments missing, will not be graded for style and formatting.
Do Not Delete Any Existing Starter Code unless directed by the instructions. Code to the given assignment, don't change the assignment to fit your code.
#include <iostream>
#include <vector>
using namespace std;
/* Define your function here */
int main() {
/* Type your code here */
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 3 images