#include <iostream>
using namespace std;
void swap(int* a, int* b);
int main()
{
int n;
int count = 0;
int min;
cin >> n;
int arr[50] = { 0 };
for (int i = 0; i < n; i++)
{
cin >> arr[i];
count++;
}
for (int i = 0; i < n-1; i++) //比较了n-1次
{
min = i;
for (int j = i + 1; j < n; j++) //最后比较下标n-2和下标n-1 。
{
if (arr[min] > arr[j])
{
min = j;
}
}
swap(&arr[min], &arr[i]);
}
for (int i = n-1; i >= n-5; i--)
{
cout << arr[i] << " ";
}
return 0;
}
void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}
using namespace std;
void swap(int* a, int* b);
int main()
{
int n;
int count = 0;
int min;
cin >> n;
int arr[50] = { 0 };
for (int i = 0; i < n; i++)
{
cin >> arr[i];
count++;
}
for (int i = 0; i < n-1; i++) //比较了n-1次
{
min = i;
for (int j = i + 1; j < n; j++) //最后比较下标n-2和下标n-1 。
{
if (arr[min] > arr[j])
{
min = j;
}
}
swap(&arr[min], &arr[i]);
}
for (int i = n-1; i >= n-5; i--)
{
cout << arr[i] << " ";
}
return 0;
}
void swap(int* a, int* b)
{
int temp = *a;
*a = *b;
*b = temp;
}