Oscar A.

asked • 04/12/20

Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order.

Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow.

Ex: If the input is:

5 10 5 3 21 2

the output is:

2 3

You can assume that the list of integers will have at least 2 values.

To achieve the above, first read the integers into a vector.

Hint: Make sure to initialize the second smallest and smallest integers properly.


#include <iostream>

#include <vector>

using namespace std;


int main() {


/* Type your code here. */


return 0;

}



2 Answers By Expert Tutors

By:

Saqib H. answered • 04/12/20

Tutor
5.0 (47)

PhD in Computer Science with expertise in Python

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.