Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- typedef struct point point;
- struct point {
- int x;
- int y;
- int z; };
- void fnc(struct point arr[], int k, int *w1,int *w2)
- {int i, j;
- double dist, t;
- for(i=0; i<k-1 ;i++){
- for (j=i+1; j<k;j++){
- if((t=sqrt(
- pow((arr[j].x - arr[i].x), 2)+
- pow((arr[j].y - arr[i].y), 2)+
- pow((arr[j].z - arr[i].z), 2) ))>dist){
- dist = t;
- printf("dist %lf i:%d j:%d\n",dist,i,j);
- *w1=i;
- *w2=j;
- }
- }
- }
- }
- int main ()
- {
- int w1,w2 ;
- struct point arr[7] =
- {
- {1,2,3},
- {3,5,7},
- {4,2,3},
- {5,1,7},
- {6,2,3},
- {1,6,3},
- {1,5,3}
- };
- fnc(arr,7,&w1,&w2);
- printf("najdalsze punkty to %d %d",w1,w2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement