# Write a program that gets a list of integers from input, and outputs the integers in ascending order (lowest to highest). The first integer indicates how many numbers are in the list. Assume that the list will always contain less than 20 integers.Ex: If the input is:5 10 4 39 12 2the output is:2 4 10 12 39For coding simplicity, follow every output value by a space, including the last one.Your program must define and call the following function. When the SortVector function is complete, the vector passed in as the parameter should be sorted.void SortVector(vector<int>& myVec)#include <iostream>#include <vector>using namespace std;/* Define your function here */int main() {/* Type your code here */return 0;}Please help me with this problem using c++.

Question
36 views

Write a program that gets a list of integers from input, and outputs the integers in ascending order (lowest to highest). The first integer indicates how many numbers are in the list. Assume that the list will always contain less than 20 integers.

Ex: If the input is:

5 10 4 39 12 2

the output is:

2 4 10 12 39

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

Your program must define and call the following function. When the SortVector function is complete, the vector passed in as the parameter should be sorted.
void SortVector(vector<int>& myVec)

#include <iostream>
#include <vector>
using namespace std;

/* Define your function here */

int main() {
/* Type your code here */

return 0;
}

check_circle

star
star
star
star
star
1 Rating
Step 1

Program:

#include<iostream>

#include<vector>

using namespace std;

void SortVector(vector<int>& myVec)

{

int n = myVec.size();

int i, j;

for (i = 0; i < n-1; i++)

for (j = 0; j < n-i-1; j++)

if (myVec[j] > myVec[j+1])

{

int temp = myVec[j];

myVec[j] = myVec[j+1];

myVec[j+1] = temp;

}

}

int main()

{

int i, num, value;

cout << "Ente...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

### Computer Science 