PROBLEM 91
Hard

Sort Three Numbers

Programming Basics · C++

</>
STATUS Not solved

TASK

Problem

#91

Given three integers, print them in nondecreasing order separated by spaces.

EXAMPLE

Example

Input
3 1 2
Output
1 2 3

LIMITS

Constraints

Each input value has absolute value at most 10^9.
📖
LEARN Theory for this problem
+

These exercises combine arithmetic, comparisons, and small branches. Keep each condition explicit and easy to verify.

Connection to “Sort Three Numbers”: here, `std::sort` orders a range, while a comparator defines which of two elements should come first.

💡
NEED HELP? Hints
+

['Break the task into a few simple checks instead of compressing everything into a clever expression.', 'After solving “Sort Three Numbers”, verify the algorithm on your own small example and on an allowed boundary case. Print only the required result with no extra text.']

ANSWER Solution
+
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    long long a,b,c;
    cin >> a >> b >> c;
    vector<long long> v= {
        a,b,c
    }
    ;
    sort(v.begin(),v.end());
    cout << v[0] << ' ' << v[1] << ' ' << v[2] << '\n';
    return 0;
}