Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template<typename Type, typename... Args>
- Type min(Args... args) {
- auto seq = initializer_list<Type>({ args... });
- auto mn = numeric_limits<Type>::max();
- for (auto value : seq) if (value < mn) mn = value;
- return mn;
- }
- template<typename Type, typename... Args>
- Type max(Args... args) {
- auto seq = initializer_list<Type>({ args... });
- auto mx = numeric_limits<Type>::min();
- for (auto value : seq) if (value > mx) mx = value;
- return mx;
- }
- int main() {
- cout << ">>> ";
- int a, b, c, d;
- cin >> a >> b >> c >> d;
- const auto mn = min<int>(a, b, c, d);
- const auto mx = max<int>(a, b, c, d);
- cout << "min: " << mn << "\nmax: " << mx << endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement