1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
#include <algorithm>
#include <array>
using namespace std;
int main()
{
array<int, 20> number_list {63, 20, 19, 3, 1, 89, 14, 400, 18, 78, 64, 12, 56, 45, 40, 35, 800, 5, 2, 52};
if (!is_sorted(number_list.begin(), number_list.end()))
{
cout << "Unsorted Array:\n";
for (int i = 0; i < 20; i++)
{
cout << number_list[i] << "\n";
}
cout << "\n";
sort(number_list.begin(), number_list.end());
if (is_sorted(number_list.begin(), number_list.end()))
{
cout << "Sorted Array:\n";
for (int i = 0; i < 20; i++)
{
cout << number_list[i] << "\n";
}
cout << "\n";
}
}
}
|