From 95bd3531e70768ab4f708b5333861b06bccd1a4e Mon Sep 17 00:00:00 2001
From: Florian Burgener <florian.burgener@hesge.ch>
Date: Tue, 7 Dec 2021 14:49:53 +0100
Subject: [PATCH] Validation exercice 4

---
 ex4/main.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/ex4/main.c b/ex4/main.c
index 08ba61b..bbd146c 100644
--- a/ex4/main.c
+++ b/ex4/main.c
@@ -1,7 +1,7 @@
 /**
  * @file main.c
- * @author Prénom Nom
- * @brief Exercice 1
+ * @author Florian Burgener
+ * @brief Exercice 4
  * @version 1.0
  * @date 2021-12-07
  * 
@@ -9,12 +9,9 @@
  * 
  */
 
-#include <math.h>
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #include "stack.h"
 
@@ -22,18 +19,21 @@ int main() {
     int32_t tab_length = 7;
     double tab[tab_length];
 
+    // Retrieves the input numbers.
     for (int32_t i = 0; i < tab_length; i += 1) {
         double number;
         scanf("%lf", &number);
         tab[i] = number;
     }
 
+    // Initialization of the algorithm.
     int32_t interv[tab_length];
     interv[0] = 1;
     stack s;
-    stack_init(&s, 1000);
+    stack_init(&s, tab_length);
     stack_push(&s, 0);
 
+    // For each number in tab.
     for (int32_t i = 0; i < tab_length; i += 1) {
         while (true) {
             int32_t top_value;
@@ -46,6 +46,7 @@ int main() {
             stack_pop(&s, &top_value);
         }
 
+        // Sets interv[i]
         if (stack_is_empty(s)) {
             interv[i] = i + 1;
         } else {
@@ -59,6 +60,7 @@ int main() {
 
     printf("\n");
 
+    // Displays the interv array.
     for (int32_t i = 0; i < tab_length; i += 1) {
         printf("%d\n", interv[i]);
     }
-- 
GitLab