#include <iostream>
using namespace std;
int main()
{
const int N = 3;
int arr[N];
int min, mid, max;
cout << "Enter a first integer number: ";
cin >> arr[0];
cout << "Enter a second integer number: ";
cin >> arr[1];
cout << "Enter a third integer number: ";
cin >> arr[2];
// sort the numbers
min = mid = max = arr[0];
for (int i = 0; i < N; ++i)
{
int tmpMin = arr[i];
for (int j = i+1; j < N; ++j)
{
if(arr[j] < tmpMin)
{
tmpMin = arr[j];
arr[j] = arr[i];
arr[i] = tmpMin;
}
}
}
cout << endl << "Ascending order from the smallest to largest: " << arr[0] << " \t "<< arr[1] << " \t "<< arr[2] << endl;
return 0;
}
Comments
Leave a comment