ex02 starting
This commit is contained in:
64
ex02/main.cpp
Normal file
64
ex02/main.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/03/21 17:00:50 by aortigos #+# #+# */
|
||||
/* Updated: 2026/03/21 17:00:54 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "Array/Array.hpp"
|
||||
|
||||
#define MAX_VAL 750
|
||||
int main(int, char**)
|
||||
{
|
||||
Array<int> numbers(MAX_VAL);
|
||||
int* mirror = new int[MAX_VAL];
|
||||
srand(time(NULL));
|
||||
for (int i = 0; i < MAX_VAL; i++)
|
||||
{
|
||||
const int value = rand();
|
||||
numbers[i] = value;
|
||||
mirror[i] = value;
|
||||
}
|
||||
//SCOPE
|
||||
{
|
||||
Array<int> tmp = numbers;
|
||||
Array<int> test(tmp);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_VAL; i++)
|
||||
{
|
||||
if (mirror[i] != numbers[i])
|
||||
{
|
||||
std::cerr << "didn't save the same value!!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
numbers[-2] = 0;
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
try
|
||||
{
|
||||
numbers[MAX_VAL] = 0;
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << '\n';
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_VAL; i++)
|
||||
{
|
||||
numbers[i] = rand();
|
||||
}
|
||||
delete [] mirror;//
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user