#include
# define MAX 100
Struct point
{
Double x;
Double y;
};
Struct point p (MAX);//The given points
Int pnum;//The number of The given points
Int idex (MAX);//The indexes of points of convex hull -
Int inum=0;//The number of The indexes
Void input ()
{
int i, j;
//fp=fopen (". \ \ closest_pair TXT ", "r");
The scanf (" % d ", & amp; Pnum);//First line is the number of points
//The following lines are The points
For (I=0; I & lt; Pnum; I++)
Lf the scanf (" % % lf ", & amp; P [I]. X, & amp; P [I] y);
Printf (" There are % d points: \ n ", pnum);
For (j=0; J & lt; Pnum; J++)
Printf (" % % 0 lf, 0 lf \ n ", p [j]. J x, p [j]. J y);
}
Void the output ()
{
int i;
Printf (" The convex hull is - \ n ");
For (I=0; I & lt; Inum; I++)
Printf (" (lf). % % 0 lf, 0 \ n ", p [idex [I]]. X, p [idex [I]]. Y);
}
Void addIndex (int idex1, int idex2)
{
int i;
Int the find=0;//To indicate been the two points are collected
For (I=0; I & lt; Inum; I++)
{
If (idex [I]==idex1)
Find +=1;
If (idex [I]==idex2)
Find +=2;
}
The switch (find)
{
Case 0://to Both of the points are not collected
Idex [inum]=idex1;
Idex [inum + 1]=idex2;
Inum +=2;
break;
Case 1://Point 1 is collected
Idex [inum]=idex2;
Inum++;
break;
Case 2://Point 2 is collected
Idex [inum]=idex1;
Inum++;
}
}
Void the process ()
{
/* * * * * * * * * * the Begin * * * * * * * * * */
//fill algorithm code here
/* * * * * * * * * * End * * * * * * * * * */
}
Int main ()
{
The input ();
The process ();
The output ();
return 0;
}
CodePudding user response:
Always feel that this topic, and should not be directly to answerSee the title, should not take an examination of the c language is the convex hull algorithm, this time to give you the code for learning without any help value
Don't understand algorithm can ask questions, and then to write, write some code, if there is a problem can continue to ask
CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.htmlI hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html