|
对三维数组进行排序,x相等时比较y的大小,y相等时比较z的大小,用到qsort函数。
c语言代码
#include
#include
struct str
{
int x;
int y;
int z;
}a[502];
int cmp(const void *p,const void *q)
{
str *c=(str *)p;
str *d=(str *)q;
if(c->x!=d->x)
return c->x-d->x;
else if(c->y!=d->y)
return c->y-d->y;
else
return c->z-d->z;
}
int main()
{
int n, i, j, k, t;
scanf("%d",&n);
for(i=0;i 0 Then
'根据数据分断方向标识,对界内特征点数据排序
Select Case FXrect
Case "x"
Dim ptstmp = From pt In listPoint1 Select pt Order By pt.X, pt.Y
'//按x为主,y为辅的升序排列
listPoint1 = ptstmp.ToList()
Case "y"
Dim ptstmp = From pt In listPoint1 Select pt Order By pt.Y, pt.X
'//按y为主,x为辅的升序排列
listPoint1 = ptstmp.ToList()
End Select
'添加界内特征点(剔除XY坐标相同点)进总特征点集
For m = 0 To n - 1
If m = 0 Then
VerPoint.Add(listPoint1(m))
Else
If listPoint1(m).X listPoint1(m - 1).X Or listPoint1(m).Y listPoint1(m - 1).Y Then
VerPoint.Add(listPoint1(m))
End If
End If
Next
'listPoint1.Clear()
End If |
|