개요
- 주어진 값 중 가장 작은 값과 가장 큰 값을 반환
예제
- 코드
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
{
auto result = minmax(7, 1);
cout << result.first << ", " << result.second << endl;
}
cout << "------" << endl;
{
auto result = minmax(7, 1, [](int a, int b) { return a > b; });
cout << result.first << ", " << result.second << endl;
}
cout << "------" << endl;
{
auto result = minmax({3, 1, 2, 7, 5, 4, 6});
cout << result.first << ", " << result.second << endl;
}
cout << "------" << endl;
{
auto result =
minmax({3, 1, 2, 7, 5, 4, 6}, [](int a, int b) { return a > b; });
cout << result.first << ", " << result.second << endl;
}
return 0;
}
- 실행 결과
1, 7
------
7, 1
------
1, 7
------
7, 1