diff --git a/ex4/main.c b/ex4/main.c index 6550e291ef06e7676d8dfb2bf08dd772777aedc7..f066d72e14f1fd4731bfaad1f4cb0ffe6a6849d6 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 +}