#include <stdio.h>
#include <stdlib.h>
#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");
scanf("%d", &pnum); // First line is the number of points
// The following lines are the points
for (i = 0; i < pnum; i++)
scanf("%lf %lf", &p[i].x, &p[i].y);
printf("There are %d points:\n", pnum);
for (j = 0; j < pnum; j++)
printf("%.0lf,%.0lf\n", p[j].x, p[j].y);
}
void output()
{
int i;
printf("The convex-hull is\n");
for (i = 0; i < inum; i++)
printf("(%.0lf,%.0lf)\n", p[idex[i]].x, p[idex[i]].y);
}
void addIndex(int idex1, int idex2)
{
int i;
int find = 0; // To indicate whether the two points are collected
for (i = 0; i < inum; i++)
{
if (idex[i] == idex1)
find += 1;
if (idex[i] == idex2)
find += 2;
}
switch (find)
{
case 0: // 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 process()
{
/********** Begin **********/
//在此處填寫演算法代碼
/********** End **********/
}
int main()
{
input();
process();
output();
return 0;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/153051.html
標籤:數據結構與算法
上一篇:silvaco
下一篇:vensim 敏感性分析
