1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex2.4/test.cpp

46 lines
1.2 KiB
C++
Raw Normal View History

#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;
}
int main() {
double dbl_a = 2.31233;
2019-12-03 10:32:24 +01:00
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;
2019-12-03 10:32:24 +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;
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;
return 0;
}