C Programming Given Write a closest Pair Function Deliverabl
C++ Programming
Given:
Write a closest Pair Function:
Deliverables
ClosestPair.h
ClosestPair.cpp
Solution
code:
Pair Closest_Pair( Point P[ ], int n)
{
float min = FLT_MAX;
int indexone=0;
int indextwo=0;
for (int i = 0; i < n; ++i)
for (int j = i+1; j < n; ++j)
if (dist(P[i], P[j]) < min)
{
min = dist(P[i], P[j]);
indexone=i;
indextwo=j;
}
Struct Pair st ;
st.indexPointOne = indexone;
st.indexPointTwo = indextwo;
return min;
}
float dist(Point p1, Point p2)
{
return sqrt( (p1.x - p2.x)*(p1.x - p2.x) +
(p1.y - p2.y)*(p1.y - p2.y)
);
}
![C++ Programming Given: Write a closest Pair Function: Deliverables ClosestPair.h ClosestPair.cppSolutioncode: Pair Closest_Pair( Point P[ ], int n) { float min C++ Programming Given: Write a closest Pair Function: Deliverables ClosestPair.h ClosestPair.cppSolutioncode: Pair Closest_Pair( Point P[ ], int n) { float min](/WebImages/28/c-programming-given-write-a-closest-pair-function-deliverabl-1078284-1761565870-0.webp)