這是我的代碼當我嘗試對結構向量進行排序時,我在算法文件中收到20個錯誤。我不知道什麼是錯的?
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <set>
#include <struct.h>
#include <vector>
#include <functional>
using namespace std;
struct points {
int x,y;
};
bool operator<(const points &p1, const points &p2) {
return p1.x<p2.x;
};
vector<points> a(1000000);
int i,n,closest;
int main() {
scanf("%d\n",&n);
for (i=0; i<n-1; i++) {
scanf("%d %d\n",&a[i].x,&a[i].y);
}
sort(0,n-1,a);
return 0;
}
,我得到的大多是國家的錯誤「需要的間接指針操作數(‘詮釋’無效)。出了什麼問題?我想在矢量內的結構進行排序。我有使用運算符重載
嘗試布爾運算符<(常規點p1,常數點p2)沒有& – 2014-10-28 16:32:00
您嘗試過哪些調試? – mskfisher 2014-10-28 16:32:40
謝謝,但它沒有工作 – user3572917 2014-10-28 16:32:55