first push cpp08
This commit is contained in:
parent
320017fc09
commit
b9acd5add2
37
cpp08/ex00/Makefile
Normal file
37
cpp08/ex00/Makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Makefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2022/08/07 19:53:15 by apommier #+# #+# #
|
||||||
|
# Updated: 2022/08/07 19:53:28 by apommier ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
NAME = a.out
|
||||||
|
SRCS = main.cpp
|
||||||
|
|
||||||
|
OBJS = ${SRCS:.cpp=.o}
|
||||||
|
CC = c++
|
||||||
|
CFLAGS = -Wall -Wextra -Werror -std=c++98
|
||||||
|
RM = rm -rf
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CC) ${CFLAGS} -c $< -o $(<:.cpp=.o)
|
||||||
|
|
||||||
|
${NAME}: ${OBJS}
|
||||||
|
${CC} ${LIB} ${OBJS} -o ${NAME}
|
||||||
|
|
||||||
|
all: ${NAME}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@${RM} ${OBJS}
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
@${RM} ${NAME}
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
.PHONY: all clean fclean re
|
||||||
23
cpp08/ex00/easyfind.hpp
Normal file
23
cpp08/ex00/easyfind.hpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* easyfind.hpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/08/07 19:53:14 by apommier #+# #+# */
|
||||||
|
/* Updated: 2022/08/07 20:22:02 by apommier ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
typename T::iterator easyfind(T &tab, int toFind)
|
||||||
|
{
|
||||||
|
typename T::iterator result = find(tab.begin(), tab.end(), toFind);
|
||||||
|
return (result);
|
||||||
|
}
|
||||||
48
cpp08/ex00/main.cpp
Normal file
48
cpp08/ex00/main.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* main.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/08/07 19:53:12 by apommier #+# #+# */
|
||||||
|
/* Updated: 2022/08/07 20:33:43 by apommier ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "easyfind.hpp"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void printIterator( T it, T end )
|
||||||
|
{
|
||||||
|
if (it != end)
|
||||||
|
std::cout << "Iterator: " << *it << std::endl;
|
||||||
|
else
|
||||||
|
std::cout << "Iterator reach end() of container (the value isn't in containers) " << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::vector<int> container;
|
||||||
|
std::vector<int>::iterator it;
|
||||||
|
|
||||||
|
std::cout << "====================Vector=====================\n";
|
||||||
|
for (int i = 0; i < 43; i++)
|
||||||
|
container.push_back(i);
|
||||||
|
it = easyfind(container, 42);
|
||||||
|
printIterator(it, container.end());
|
||||||
|
it = easyfind(container, 43);
|
||||||
|
printIterator(it, container.end());
|
||||||
|
|
||||||
|
std::cout << "====================Deque=====================\n";
|
||||||
|
std::deque<char> container2;
|
||||||
|
std::deque<char>::iterator it2;
|
||||||
|
for (int i = 0; i < 43; i++)
|
||||||
|
container2.push_back(i);
|
||||||
|
it2 = easyfind(container2, 42);
|
||||||
|
printIterator(it2, container2.end());
|
||||||
|
it2 = easyfind(container2, 43);
|
||||||
|
printIterator(it2, container2.end());
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
37
cpp08/ex01/Makefile
Normal file
37
cpp08/ex01/Makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Makefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2022/08/07 20:32:52 by apommier #+# #+# #
|
||||||
|
# Updated: 2022/08/07 20:33:01 by apommier ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
NAME = a.out
|
||||||
|
SRCS = main.cpp
|
||||||
|
|
||||||
|
OBJS = ${SRCS:.cpp=.o}
|
||||||
|
CC = c++
|
||||||
|
CFLAGS = -Wall -Wextra -Werror -std=c++98
|
||||||
|
RM = rm -rf
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CC) ${CFLAGS} -c $< -o $(<:.cpp=.o)
|
||||||
|
|
||||||
|
${NAME}: ${OBJS}
|
||||||
|
${CC} ${LIB} ${OBJS} -o ${NAME}
|
||||||
|
|
||||||
|
all: ${NAME}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@${RM} ${OBJS}
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
@${RM} ${NAME}
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
.PHONY: all clean fclean re
|
||||||
58
cpp08/ex01/Span.cpp
Normal file
58
cpp08/ex01/Span.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* Span.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/08/07 20:32:51 by apommier #+# #+# */
|
||||||
|
/* Updated: 2022/08/07 22:04:55 by apommier ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
Span::Span()
|
||||||
|
{
|
||||||
|
this->_storageSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Span::Span(unsigned int size)
|
||||||
|
{
|
||||||
|
this->_storageSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
Span::Span(const Span ©)
|
||||||
|
{
|
||||||
|
*this = copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
Span::~Span()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Span::addNumber()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int Span::shortestSpan()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int Span::longestSpan()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Span::addRangeOfIterators()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Span &Span::operator=( const Span &rhs )
|
||||||
|
{
|
||||||
|
this->_storageSize = rhs._storageSize;
|
||||||
|
this->_storage = rhs._storage;
|
||||||
|
return (*this);
|
||||||
|
}
|
||||||
45
cpp08/ex01/Span.hpp
Normal file
45
cpp08/ex01/Span.hpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* Span.hpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/08/07 20:33:52 by apommier #+# #+# */
|
||||||
|
/* Updated: 2022/08/07 22:04:22 by apommier ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
class Span{
|
||||||
|
public :
|
||||||
|
|
||||||
|
Span();
|
||||||
|
Span(unsigned int size);
|
||||||
|
Span(const Span ©);
|
||||||
|
~Span();
|
||||||
|
void addNumber();
|
||||||
|
int shortestSpan();
|
||||||
|
int longestSpan();
|
||||||
|
void addRangeOfIterators();
|
||||||
|
|
||||||
|
Span &operator=( const Span &rhs );
|
||||||
|
|
||||||
|
class fullContainer : public std::exception {
|
||||||
|
char const *what() const throw()
|
||||||
|
{
|
||||||
|
return ("Container is full !");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class notEnoughNumber : public std::exception {
|
||||||
|
char const *what() const throw()
|
||||||
|
{
|
||||||
|
return ("You need at least 2 number to find a span!");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private :
|
||||||
|
|
||||||
|
std::vector<int> _storage;
|
||||||
|
int _storageSize;
|
||||||
|
}
|
||||||
16
cpp08/ex01/main.cpp
Normal file
16
cpp08/ex01/main.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* main.cpp :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/08/07 20:32:50 by apommier #+# #+# */
|
||||||
|
/* Updated: 2022/08/07 20:33:25 by apommier ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
37
cpp08/ex02/Makefile
Normal file
37
cpp08/ex02/Makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# **************************************************************************** #
|
||||||
|
# #
|
||||||
|
# ::: :::::::: #
|
||||||
|
# Makefile :+: :+: :+: #
|
||||||
|
# +:+ +:+ +:+ #
|
||||||
|
# By: apommier <apommier@student.42.fr> +#+ +:+ +#+ #
|
||||||
|
# +#+#+#+#+#+ +#+ #
|
||||||
|
# Created: 2022/08/07 19:53:32 by apommier #+# #+# #
|
||||||
|
# Updated: 2022/08/07 19:53:35 by apommier ### ########.fr #
|
||||||
|
# #
|
||||||
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
NAME = a.out
|
||||||
|
SRCS = main.cpp
|
||||||
|
|
||||||
|
OBJS = ${SRCS:.cpp=.o}
|
||||||
|
CC = c++
|
||||||
|
CFLAGS = -Wall -Wextra -Werror -std=c++98
|
||||||
|
RM = rm -rf
|
||||||
|
|
||||||
|
.cpp.o:
|
||||||
|
$(CC) ${CFLAGS} -c $< -o $(<:.cpp=.o)
|
||||||
|
|
||||||
|
${NAME}: ${OBJS}
|
||||||
|
${CC} ${LIB} ${OBJS} -o ${NAME}
|
||||||
|
|
||||||
|
all: ${NAME}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@${RM} ${OBJS}
|
||||||
|
|
||||||
|
fclean: clean
|
||||||
|
@${RM} ${NAME}
|
||||||
|
|
||||||
|
re: fclean all
|
||||||
|
|
||||||
|
.PHONY: all clean fclean re
|
||||||
0
cpp08/ex02/MutantStack.hpp
Normal file
0
cpp08/ex02/MutantStack.hpp
Normal file
0
cpp08/ex02/main.cpp
Normal file
0
cpp08/ex02/main.cpp
Normal file
Loading…
Reference in New Issue
Block a user