1int main()
2{
3 // Get the vector
4 vector<int> a = { 1, 45, 54, 71, 76, 12 };
5
6 // Print the vector
7 cout << "Vector: ";
8 for (int i = 0; i < a.size(); i++)
9 cout << a[i] << " ";
10 cout << endl;
11
12 // Find the max element
13 cout << "\nMax Element = "
14 << *max_element(a.begin(), a.end());
15 return 0;
16}
1#include <iostream>
2#include <algorithm>
3
4template <typename T, size_t N> const T* mybegin(const T (&a)[N]) { return a; }
5template <typename T, size_t N> const T* myend (const T (&a)[N]) { return a+N; }
6
7int main()
8{
9 const int cloud[] = { 1,2,3,4,-7,999,5,6 };
10
11 std::cout << *std::max_element(mybegin(cloud), myend(cloud)) << '\n';
12 std::cout << *std::min_element(mybegin(cloud), myend(cloud)) << '\n';
13}