45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#include <iostream>
|
|
|
|
#include "max.hh"
|
|
#include "min.hh"
|
|
#define LIST_SIZE 5
|
|
|
|
int min( int a, int b ) {
|
|
if ( a < b ) {
|
|
return b;
|
|
}
|
|
|
|
return a;
|
|
}
|
|
|
|
int main() {
|
|
double dbl_a = 2.31233;
|
|
double dbl_b = 2.78787;
|
|
|
|
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;
|
|
|
|
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;
|
|
std::cout << "min(" << list[4] << ", " << list[2] << ") = " << min(list[4], list[2]) << std::endl;
|
|
std::cout << std::endl;
|
|
|
|
|
|
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;
|
|
|
|
return 0;
|
|
}
|