使用vector出现的错误 subscript out of range
double ClosestPoints(vector<Point> S, int n)
{
ji = 0;cert = 0;
if (n<2)
return 99999.0;
int i, j, a = 0, b = 0, c = 0;
int p = 0, q = 0;
double dmin, d1, d2, d, r[25], m;
int ij[2][10];
Point temp;
vector <Point> S1, S2, P1, P2;
for (i = 0;i<n - 1;i++)
{
//cout << "测试3" <<S.max_size ()<< endl;
for (j = n - 1;j >= i;j--)
{
cout << i<< " "<<j<<"测试" << endl;
if (S[j].x < S[j-1].x)
{
//cout << S[j].x << " " << S[j - 1].x << endl;
temp = S.at(j);
S[j] = S[j - 1];
S[j - 1] = temp;
//cout << S[j].x << " " << S[j - 1].x << endl;
}
}
}
cout << "测试2" << endl;
}
测试后发现程序运行在循环出停止出现错误 subscript out of range i循环只能执行第一层