You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.9 KiB
48 lines
1.9 KiB
2 years ago
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* main.cpp :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2022/09/19 08:06:50 by narnaud #+# #+# */
|
||
|
/* Updated: 2022/09/19 08:07:01 by narnaud ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "Span.hpp"
|
||
|
#define RAND_SIZE 10000
|
||
|
|
||
|
int main(void) {
|
||
|
Span sp(10);
|
||
|
sp.addNumber(5);
|
||
|
sp.addNumber(4);
|
||
|
sp.addNumber(1);
|
||
|
sp.addNumber(-5);
|
||
|
|
||
|
std::cout << "5 4 1 -1" << std::endl;
|
||
|
std::cout << "Shortest span: " << sp.shortestSpan() << std::endl;
|
||
|
std::cout << "Longest span: " << sp.longestSpan() << std::endl;
|
||
|
|
||
|
Span sp2(RAND_SIZE);
|
||
|
sp2.addNRandom(RAND_SIZE);
|
||
|
|
||
|
std::cout << RAND_SIZE << " numbers between " << INT_MIN << " and " << INT_MAX
|
||
|
<< std::endl;
|
||
|
std::cout << "Shortest span: " << sp2.shortestSpan() << std::endl;
|
||
|
std::cout << "Longest span: " << sp2.longestSpan() << std::endl;
|
||
|
|
||
|
Span sp3(500);
|
||
|
std::vector<int> nums;
|
||
|
for (int n = 0; n < 500; n++) nums.push_back(n);
|
||
|
std::random_shuffle(nums.begin(), nums.end());
|
||
|
sp3.addRange(nums.begin(), nums.begin() + 20);
|
||
|
std::cout << "Sp3:" << std::endl;
|
||
|
std::cout << "Shortest span: " << sp3.shortestSpan() << std::endl;
|
||
|
std::cout << "Longest span: " << sp3.longestSpan() << std::endl;
|
||
|
|
||
|
sp3.addRange(nums.begin(), nums.end());
|
||
|
|
||
|
return (0);
|
||
|
}
|