rubidium.c (589B)
1 #include <stdio.h> 2 #include <math.h> 3 4 int func1 (int *, int *, int); 5 6 int 7 main(int argc, char **argv) 8 { 9 int d; 10 11 int a[4], b[4]; 12 13 a[0] = 0; 14 a[1] = 0; 15 a[2] = 10; 16 a[3] = 10; 17 18 b[0] = 0; 19 b[1] = 10; 20 b[2] = 0; 21 b[3] = 10; 22 23 d = func1(a, b, 4); 24 25 printf("%d\n", d); 26 27 return 0; 28 } 29 30 int 31 func1(int *x, int *y, int N) 32 { 33 int t; 34 int res; 35 36 res = sqrt(pow((x[0] - x[1]), 2) + pow((y[0] - y[1]),2)); 37 38 for (int i = 1; i < N; i++) 39 for (int j = 1; j < N; j++) 40 if (i != j) { 41 t = sqrt(pow((x[i] - x[j]),2) + 42 pow((y[i] - y[j]),2)); 43 44 if (t < res) 45 res = t; 46 } 47 return res/2; 48 }