This commit is contained in:
lfirmin 2026-03-16 16:09:42 +01:00
parent 23d21b42ca
commit 81a88d6af1
4 changed files with 43 additions and 1 deletions

14
ex01/Main.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "Span.hpp"
int main()
{
Span sp = Span(5);
sp.addNumber(6);
sp.addNumber(3);
sp.addNumber(17);
sp.addNumber(9);
sp.addNumber(11);
std::cout << sp.shortestSpan() << std::endl;
std::cout << sp.longestSpan() << std::endl;
return 0;
}

View File

@ -3,7 +3,7 @@ CXXFLAGS = -Wall -Wextra -Werror -std=c++98
OBJDIR = obj
SOURCES = Main.cpp
OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:.cpp=.o))
NAME = Easyfind
NAME = Span
all: $(NAME)

1
ex01/Span.cpp Normal file
View File

@ -0,0 +1 @@
#include "Span.hpp"

27
ex01/Span.hpp Normal file
View File

@ -0,0 +1,27 @@
#ifndef SPAN_HPP
#define SPAN_HPP
#include <string>
#include <iostream>
#include <vector>
class Span
{
private:
unsigned int _n;
std::vector<int> _vec;
public:
Span();
Span(const unsigned int n);
~Span();
Span(const Span& other);
Span &operator=(const Span& other);
int shortestSpan() const;
int longestSpan() const;
void addNumber(int x);
};
#endif