Skip to content
Snippets Groups Projects
Commit 4cf28391 authored by root's avatar root
Browse files

ex4

parent 8443b92f
Branches
No related tags found
No related merge requests found
#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
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment