// Construct an array of length MAX_POINTS.
// Populate the array with given points and initialize the number points being handled.
// Print the given points for the user.
struct Point points[MAX_POINTS];
int numPoints = readPoints(points);
printf("Set of points: \n");
displayPoints(points, numPoints);
// Construct an array to represent the hull with max possible points (numPoints).
struct Point hull[numPoints];
struct Point pointOnHull = leftmostPoint(points, numPoints);
struct Point endPoint;
int e = 0;
// Perform Jarvis March.
do {
hull[e] = pointOnHull;
endPoint = points[0];
for ( int i = 1; i < numPoints; i++ )
if ( (endPoint == pointOnHull) || (ccw(hull[e], endPoint, points[i]) > 0) )
endPoint = points[i];
++e;
} while ( endPoint != hull[0] ); // we've looped back to the beginning.
// Print the mapped hull points.
printf("Convex hull: \n");
displayPoints(hull, numPoints);
这是我的 Jarvis March(礼品包装)程序的代码,用于解决凸包问题。GCC 在我的 struct Point 比较(endPoint == pointOnHull
和endPoint != hull[0])
. 我是 C 的新手,这是我正在做的第一个使用该语言的项目之一。谁能帮我看看我在哪里搞砸了?
具体错误:
jarvis.c:31:19:错误:二进制 == 的无效操作数(具有“结构点”和“结构点”)
jarvis.c:34:21:错误:二进制操作数无效!=(具有“结构点”和“结构点”)