I'm currently stuck on a C++ problem that asks me to sort five inputted integers from least to greatest. I've tried using if statements to do this, but it just seems way too inefficient to list out all the possible combinations. I've also experimented with the min and max functions, but these only work on the smallest and largest two integers. What is the fastest way to sort them?
#include <iostream>
using namespace std;
int main() {
cout << "Enter five integers. \n\n>";
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;
int first = min({a, b, c, d, e});
int fifth = max({a, b, c, d, e});
cout << first << fifth << "\n"; //This is where I want to output the middle three integers in order
cout << "\n";
return 0;
}
Here's my code so far. ^