A C++ program to demonstrate working of std::sort(), std::reverse()
More...
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
A C++ program to demonstrate working of std::sort(), std::reverse()
◆ main()
Main function
11 {
12
13 int arr[] = {10, 20, 5, 23, 42, 15};
14 int n = sizeof(arr) / sizeof(arr[0]);
16
18 for (
int i = 0; i < n; i++)
std::cout << vect[i] <<
" ";
19
20
22
23 std::cout <<
"\nVector after sorting is: ";
24 for (
int i = 0; i < n; i++)
std::cout << vect[i] <<
" ";
25
26
28
29 std::cout <<
"\nVector after reversing is: ";
30 for (
int i = 0; i < 6; i++)
std::cout << vect[i] <<
" ";
31
32 std::cout <<
"\nMaximum element of vector is: ";
34
35 std::cout <<
"\nMinimum element of vector is: ";
37
38
39 std::cout <<
"\nThe summation of vector elements is: ";
41
42 return 0;
43}