From 4cf28391275f20257d80df49443bc3886337bac1 Mon Sep 17 00:00:00 2001
From: root <brian.crocoll@hes-so.ch>
Date: Tue, 24 Jan 2023 13:45:23 +0000
Subject: [PATCH] ex4

---
 ex4/main.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/ex4/main.c b/ex4/main.c
index 6550e29..f066d72 100644
--- a/ex4/main.c
+++ b/ex4/main.c
@@ -1,7 +1,43 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-int main(){
+typedef struct coord
+{
+	int x, y;
+} coord;
 
+uint manh(coord a, coord b){
+	return (abs(b.x - a.x) + abs(b.y - a.y));
+}
+
+int main(int argc, char const *argv[])
+{
+	if (argc < 2 || argc > 2){
+		return -1;
+	}
+
+	uint n_points = atoi(argv[1]);
+
+	coord* p_arr = (coord*) malloc(n_points * sizeof(coord));
+	for (size_t i = 0; i < n_points; i++)
+	{
+		printf("%ld point x-coord : ", i);
+		scanf("%d", &p_arr[i].x);
+		printf("\n");
+		printf("%ld point y-coord : ", i);
+		scanf("%d", &p_arr[i].y);
+	}
+	
+	for (uint i = 0; i < n_points; i++)
+	{
+		for (uint j = 0; j < n_points; j++)
+		{
+			printf("%d ", manh(p_arr[i], p_arr[j]));
+		}
+		printf("\n");
+	}
+	
+
+	free(p_arr);
 	return 0;
-}
\ No newline at end of file
+}
-- 
GitLab