From 19c4eeaa2af1b7e7a651674526b4fa6ab568a8ed Mon Sep 17 00:00:00 2001
From: Florian Burgener <florian.burgener@etu.hesge.ch>
Date: Tue, 25 Jan 2022 14:59:56 +0100
Subject: [PATCH] Validation ex4

---
 ex4/ex4.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 3 deletions(-)

diff --git a/ex4/ex4.c b/ex4/ex4.c
index 26cb2b5..4f0e921 100644
--- a/ex4/ex4.c
+++ b/ex4/ex4.c
@@ -9,18 +9,21 @@
  * 
  */
 
-#include <math.h>
-#include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 typedef struct Point {
     int32_t x;
     int32_t y;
 } Point;
 
+/**
+ * @brief Read the points that are in the input.
+ * 
+ * @param points_length 
+ * @return Point** 
+ */
 Point **read_points_from_input(int32_t points_length) {
     Point **points = (Point **)malloc(sizeof(Point) * points_length);
 
@@ -33,6 +36,13 @@ Point **read_points_from_input(int32_t points_length) {
     return points;
 }
 
+/**
+ * @brief Create a new matrix of size row x column.
+ * 
+ * @param row_count 
+ * @param column_count 
+ * @return int32_t** 
+ */
 int32_t **new_matrix(int32_t row_count, int32_t column_count) {
     int32_t **matrix = (int32_t **)malloc(sizeof(int32_t *) * row_count);
 
@@ -43,10 +53,24 @@ int32_t **new_matrix(int32_t row_count, int32_t column_count) {
     return matrix;
 }
 
+/**
+ * @brief Calculate the distance between two points.
+ * 
+ * @param p1 
+ * @param p2 
+ * @return int32_t 
+ */
 int32_t calculate_distance(Point *p1, Point *p2) {
     return abs(p2->x - p1->x) + abs(p2->y - p1->y);
 }
 
+/**
+ * @brief Calculates all possible distances with the list of points.
+ * 
+ * @param distances 
+ * @param points 
+ * @param points_length 
+ */
 void compute_distances(int32_t **distances, Point **points, int32_t points_length) {
     for (int32_t i = 0; i < points_length; i += 1) {
         for (int32_t j = 0; j < points_length; j += 1) {
@@ -55,6 +79,13 @@ void compute_distances(int32_t **distances, Point **points, int32_t points_lengt
     }
 }
 
+/**
+ * @brief Displays the matrix.
+ * 
+ * @param matrix 
+ * @param row_count 
+ * @param column_count 
+ */
 void print_matrix(int32_t **matrix, int32_t row_count, int32_t column_count) {
     for (int32_t i = 0; i < row_count; i += 1) {
         for (int32_t j = 0; j < column_count; j += 1) {
@@ -65,6 +96,12 @@ void print_matrix(int32_t **matrix, int32_t row_count, int32_t column_count) {
     }
 }
 
+/**
+ * @brief Deletes the matrix from the memory.
+ * 
+ * @param matrix 
+ * @param row_count 
+ */
 void delete_matrix(int32_t **matrix, int32_t row_count) {
     for (int32_t i = 0; i < row_count; i += 1) {
         free(matrix[i]);
@@ -73,6 +110,12 @@ void delete_matrix(int32_t **matrix, int32_t row_count) {
     free(matrix);
 }
 
+/**
+ * @brief Deletes the points from the memory.
+ * 
+ * @param points 
+ * @param points_length 
+ */
 void delete_points(Point **points, int32_t points_length) {
     for (int32_t i = 0; i < points_length; i += 1) {
         free(points[i]);
-- 
GitLab