stl

#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    // Step 1: Declare a vector of integers
    std::vector<int> numbers = {5, 2, 8, 3, 1, 7};

    // Step 2: Print the original vector
    std::cout << "Original Vector: ";
    for (const auto& num : numbers) {
        std::cout << num << " ";
    }
    std::cout << std::endl;

    // Step 3: Sort the vector in ascending order using std::sort
    std::sort(numbers.begin(), numbers.end());

    // Step 4: Print the sorted vector
    std::cout << "Sorted Vector (Ascending): ";
    for (const auto& num : numbers) {
        std::cout << num << " ";
    }
    std::cout << std::endl;

    // Step 5: Sort the vector in descending order using std::sort and a custom comparator
    std::sort(numbers.begin(), numbers.end(), std::greater<int>());

    // Step 6: Print the sorted vector in descending order
    std::cout << "Sorted Vector (Descending): ";
    for (const auto& num : numbers) {
        std::cout << num << " ";
    }
    std::cout << std::endl;

    // Step 7: Find the minimum element in the vector using std::min_element
    auto minElement = std::min_element(numbers.begin(), numbers.end());

    // Step 8: Print the minimum element
    std::cout << "Minimum Element: " << *minElement << std::endl;

    // Step 9: Find the maximum element in the vector using std::max_element
    auto maxElement = std::max_element(numbers.begin(), numbers.end());

    // Step 10: Print the maximum element
    std::cout << "Maximum Element: " << *maxElement << std::endl;

    return 0;
}