「✨」 feat: finished ex00
This commit is contained in:
60
ex00/Makefile
Normal file
60
ex00/Makefile
Normal file
@ -0,0 +1,60 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# Makefile :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2024/10/25 16:09:27 by adjoly #+# #+# #
|
||||
# Updated: 2025/04/09 14:50:44 by adjoly ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
SHELL = bash
|
||||
|
||||
NAME = whatever
|
||||
|
||||
CC = c++
|
||||
|
||||
OBJSDIR = obj/
|
||||
|
||||
SRCS = $(shell find . -name '*.cpp')
|
||||
|
||||
OBJS = $(addprefix $(OBJSDIR), $(SRCS:.cpp=.o))
|
||||
|
||||
FLAGS = -Wall -Werror -Wextra -std=c++98 -MMD -MP
|
||||
|
||||
RED = \033[0;31m
|
||||
GREEN = \033[0;32m
|
||||
YELLOW = \033[1;33m
|
||||
PURPLE = \e[0;35m
|
||||
NC = \033[0m
|
||||
DELETE = \x1B[2K\r
|
||||
|
||||
ifeq ($(VERBOSE),true)
|
||||
FLAGS += -D VERBOSE
|
||||
endif
|
||||
|
||||
all: $(NAME)
|
||||
|
||||
$(NAME): $(OBJS)
|
||||
@$(CC) $(FLAGS) -I . $(OBJS) -o $(NAME)
|
||||
@printf "$(YELLOW)「✨」($(NAME)) Program compiled\n"
|
||||
|
||||
$(OBJSDIR)%.o: %.cpp
|
||||
@mkdir -p $(@D)
|
||||
@$(CC) $(FLAGS) -I . -c $< -o $@
|
||||
@printf "$(DELETE)$(GREEN)「🔨」($<) Object compiled\n"
|
||||
|
||||
clean:
|
||||
@rm -f $(OBJS)
|
||||
@printf "$(DELETE)$(RED)「🗑️」($(OBJS)) Object deleted\n"
|
||||
|
||||
fclean: clean
|
||||
@rm -f $(NAME)
|
||||
@rm -Rf $(OBJSDIR)
|
||||
@printf "$(RED)「🗑️」($(NAME)) Program deleted\n"
|
||||
|
||||
re: fclean all
|
||||
|
||||
.PHONY: clean fclean all re
|
29
ex00/main.cpp
Normal file
29
ex00/main.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* main.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/09 14:29:59 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/09 14:51:07 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "whatever.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int main(void) {
|
||||
int a = 2;
|
||||
int b = 8;
|
||||
|
||||
std::cout << "a: " << a << " and b: " << b << std::endl;
|
||||
std::cout << "min betweeen a and b: " << min(a, b) << std::endl;
|
||||
std::cout << "max betweeen a and b: " << max(a, b) << std::endl;
|
||||
std::cout << "swapping a and b" << std::endl;
|
||||
swap(a, b);
|
||||
std::cout << "a: " << a << " and b: " << b << std::endl;
|
||||
std::cout << "min betweeen a and b: " << min(a, b) << std::endl;
|
||||
std::cout << "max betweeen a and b: " << max(a, b) << std::endl;
|
||||
|
||||
}
|
3
ex00/obj/main.d
Normal file
3
ex00/obj/main.d
Normal file
@ -0,0 +1,3 @@
|
||||
obj/./main.o: main.cpp whatever.hpp
|
||||
|
||||
whatever.hpp:
|
BIN
ex00/obj/main.o
Normal file
BIN
ex00/obj/main.o
Normal file
Binary file not shown.
BIN
ex00/whatever
Executable file
BIN
ex00/whatever
Executable file
Binary file not shown.
37
ex00/whatever.hpp
Normal file
37
ex00/whatever.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* whatever.hpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/04/09 14:30:38 by adjoly #+# #+# */
|
||||
/* Updated: 2025/04/09 14:38:49 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#pragma once
|
||||
|
||||
template <typename T> void swap(T &a, T &b) {
|
||||
T tmp;
|
||||
|
||||
tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
}
|
||||
|
||||
template <typename T> T min(T &a, T &b) {
|
||||
if (a > b) {
|
||||
return b;
|
||||
} else {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T> T max(T &a, T&b) {
|
||||
if (a < b) {
|
||||
return b;
|
||||
} else {
|
||||
return a;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user