Yesterday I went for an interview where I have been asked to create a program to find largest and smallest among 5 numbers without using array.
I know how to create
#include
#include
template
inline const T&
max_of(const T& a, const T& b) {
return std::max(a, b);
}
template
inline const T&
max_of(const T& a, const T& b, const Args& ...args) {
return max_of(std::max(a, b), args...);
}
int main() {
std::cout << max_of(1, 2, 3, 4, 5) << std::endl;
// Or just use the std library:
std::cout << std::max({1, 2, 3, 4, 5}) << std::endl;
return 0;
}