0
我有凸包算法:语法错误
#include <cstdlib>
#include <iostream>
using namespace std;
typedef int point;
void convexhull(point x[],bool onedge){
int N=sizeof(x)/sizeof(int);
int p=0;
bool used=new bool[N];
for (int i=1;i<N;i++){
if (x[i]<x[p])
p=i;
}
int start=p;
do
{
int n=-1;
int dist=onedge?32756:0;
for (int i=0;i<N;i++){
//dont go back to the same point you come from
if (i==p) continue;
if (used[i]) continue;
//if there is not such N yet,set it to x
if (n==-1) n=i;
int cross=(x[i]-x[p])*(x[n]-x[p]);
//d is distance from P to x
int d=(x[i]-x[p])*(x[i]-x[p]);
if (cross<0){
n=i;
dist=d;
}
else if (cross==0){
//in this case both N and X are4 in the
//same direction.if onedge is true
//pick the closest one,otherwidr pick farthest one
if (onedge && d<dist){
dist=d;
n=i;
}
else if (!onedge && d>dist)}
dist=d;
n=i;
}
}
}
p=n;
used[p]=true;
} while(start!=p);
}
int main(int argc, char *argv[])
{
system("PAUSE");
return EXIT_SUCCESS;
}
但是,当我编译它,它让我看到象这样的错误:
26 G:\convex_hull.cpp invalid types `bool[int]' for array subscript
48 G:\convex_hull.cpp expected primary-expression before '}' token
67 G:\convex_hull.cpp expected `,' or `;' before '=' token
请帮助我了解什么是错的。我不能使用整数下标与布尔数组?