From de6fb34db909d06b1c881055725a820fc0060ef3 Mon Sep 17 00:00:00 2001
From: Florian Burgener <florian.burgener@hesge.ch>
Date: Tue, 7 Dec 2021 14:30:27 +0100
Subject: [PATCH] Validation exercice 5

---
 ex5/main.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/ex5/main.c b/ex5/main.c
index 0572f98..ef3ec7e 100644
--- a/ex5/main.c
+++ b/ex5/main.c
@@ -1,7 +1,7 @@
 /**
  * @file main.c
- * @author Prénom Nom
- * @brief Exercice 1
+ * @author Florian Burgener
+ * @brief Exercice 5
  * @version 1.0
  * @date 2021-12-07
  * 
@@ -9,21 +9,29 @@
  * 
  */
 
-#include <math.h>
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
+/**
+ * @brief Sort the table in reverse order.
+ * 
+ * @param array 
+ * @param array_length 
+ * @param i 
+ */
 void reverse_array(double *array, int32_t array_length, int32_t i) {
     if (i == array_length / 2) {
+        // Stops when half of the array is reached, the array is now reversed.
         return;
     }
 
     double tmp = array[i];
+    // Swap value from right side to the left side.
     array[i] = array[array_length - 1 - i];
+    // Swap value from left side to the right side.
     array[array_length - 1 - i] = tmp;
+
     reverse_array(array, array_length, i + 1);
 }
 
@@ -31,6 +39,7 @@ int main() {
     int32_t array_length = 6;
     double array[array_length];
 
+    // Retrieves the input numbers.
     for (int32_t i = 0; i < array_length; i += 1) {
         double number;
         scanf("%lf", &number);
@@ -40,6 +49,7 @@ int main() {
     reverse_array(array, array_length, 0);
     printf("\n");
 
+    // Displays the array once it has been inverted.
     for (int32_t i = 0; i < array_length; i += 1) {
         printf("%.1lf\n", array[i]);
     }
-- 
GitLab