Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have to write a C++ function called sort that will take in a reference to a vector and sort it in ascending order. This

I have to write a C++ function called sort that will take in a reference to a vector and sort it in ascending order. This is my function so far, I just don't know how to sort it in ascending order.

#include #include using namespace std;

vector sort(vector &a) { int max; vector sorted; for(int i=0; i

}

int main() {

int n; cin >> n; vector a; int temp; while(true) { cin >> temp; if(temp <0) { break; } else { a.push_back(temp); } } sort(a);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago