feat(08 ex01): adding the multiple numbers in single call

This commit is contained in:
Raphael 2025-04-04 15:10:07 +02:00
parent 59e5b448f2
commit eb1cebe50b
2 changed files with 33 additions and 2 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/03 14:09:32 by rparodi #+# #+# */
/* Updated: 2025/04/03 15:21:18 by rparodi ### ########.fr */
/* Updated: 2025/04/04 15:07:59 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
@ -24,8 +24,24 @@ int main() {
std::cout << CLR_BLUE << "Shortest span: " << CLR_GOLD << sp.shortestSpan() << CLR_RESET << std::endl;
std::cout << CLR_BLUE << "Longest span: " << CLR_GOLD << sp.longestSpan() << CLR_RESET << std::endl;
} catch (std::exception &e) {
std::cerr << CLR_RED << "Exception: " << e.what() << CLR_RESET << std::endl;
std::cerr << CLR_RED << "Error: " << e.what() << CLR_RESET << std::endl;
}
try {
std::cout << std::endl<< CLR_YELLOW << "[ AddNumbers method ]" << CLR_RESET << std::endl;
Span sp = Span(2);
std::vector<int> vec;
vec.push_back(7);
vec.push_back(13);
sp.addNumbers(vec.begin(), vec.end());
std::cout << CLR_BLUE << "Shortest span: " << CLR_GOLD << sp.shortestSpan() << CLR_RESET << std::endl;
std::cout << CLR_BLUE << "Longest span: " << CLR_GOLD << sp.longestSpan() << CLR_RESET << std::endl;
vec.clear();
vec.push_back(42);
vec.push_back(21);
sp.addNumbers(vec.begin(), vec.end());
} catch (std::exception(&e)) {
std::cerr << CLR_RED << "Error: " << e.what() << CLR_RESET << std::endl;
}
return 0;
}