2019-11-26 10:55:12 +01:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include "max.hh"
|
|
|
|
#include "min.hh"
|
|
|
|
#define LIST_SIZE 5
|
2019-12-03 10:32:24 +01:00
|
|
|
|
|
|
|
int min( int a, int b ) {
|
|
|
|
if ( a < b ) {
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2019-11-26 10:55:12 +01:00
|
|
|
int main() {
|
|
|
|
double dbl_a = 2.31233;
|
2019-12-03 10:32:24 +01:00
|
|
|
double dbl_b = 2.78787;
|
2019-11-26 10:55:12 +01:00
|
|
|
|
|
|
|
int list[ LIST_SIZE ] = { 0, 2 ,4 , 6, -9 };
|
|
|
|
|
|
|
|
|
|
|
|
std::cout << "Doubles" << std::endl;
|
|
|
|
std::cout << "max(" << dbl_a << ", " << dbl_b << ") = " << mylib::max(dbl_a, dbl_b ) << std::endl;
|
|
|
|
std::cout << "min(" << dbl_a << ", " << dbl_b << ") = " << mylib::min(dbl_a, dbl_b ) << std::endl;
|
|
|
|
std::cout << std::endl;
|
2019-12-03 10:32:24 +01:00
|
|
|
|
2019-11-26 10:55:12 +01:00
|
|
|
std::cout << "Int & Doubles" << std::endl;
|
|
|
|
std::cout << "max(" << list[4] << ", " << dbl_b << ") = " << mylib::max(list[4], dbl_b ) << std::endl;
|
|
|
|
std::cout << "min(" << list[4] << ", " << dbl_b << ") = " << mylib::min(list[4], dbl_b ) << std::endl;
|
2019-12-03 10:32:24 +01:00
|
|
|
std::cout << "min(" << list[4] << ", " << list[2] << ") = " << min(list[4], list[2]) << std::endl;
|
2019-11-26 10:55:12 +01:00
|
|
|
std::cout << std::endl;
|
|
|
|
|
2019-12-03 10:32:24 +01:00
|
|
|
|
|
|
|
std::cout << "List = [";
|
|
|
|
for (int i = 0; i < LIST_SIZE; i++ )
|
|
|
|
{
|
|
|
|
std::cout << list[i] << ", ";
|
|
|
|
}
|
|
|
|
std::cout << "]" << std::endl;
|
|
|
|
|
|
|
|
std::cout << "max( list, LIST_SIZE) = " << mylib::max( list, LIST_SIZE ) << std::endl;
|
|
|
|
std::cout << "min( list, LIST_SIZE) = " << mylib::min( list, LIST_SIZE ) << std::endl;
|
2019-11-26 10:55:12 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|