63,579
社区成员




#include "iostream"
#include "vector"
using namespace std;
struct NODE{
double i;
double j;
NODE() {
i=0;
j=0;
}
NODE( const NODE &node){
i=node.i;
j=node.j;
}
};
class LocalNode{
public:
NODE A;
int dist;// the correlation number
LocalNode() {
A.i=0;
A.j=0;
dist=0;
}
LocalNode( const LocalNode& RightSides){
dist=RightSides.dist;
A.i=RightSides.A.i;
A.j=RightSides.A.j;
}
void setR( const NODE a,const int c){
A.i=a.i;
A.j=a.j;
dist=c;
}
LocalNode& operator = ( LocalNode const& a ){
if( this != &a ){
A.i=a.A.i;
A.j=a.A.j;
dist=a.dist;
}
return *this;
}
bool operator < (const LocalNode &m)const {
return dist < m.dist;
}
bool operator > (const LocalNode &m)const {
return dist> m.dist;
}
bool operator == (const LocalNode &m)const {
return dist== m.dist;
}
};
void main (){
NODE p;
vector <NODE> vect;
for(int i=0;i <10;i++){
p.i=i;
p.j=2*i;
vect.push_back(p);
}
vector <LocalNode> local_node ;
LocalNode node;
int NUM=vect.size();
local_node.reserve(NUM);
for(int num = 0 ; num < NUM; num ++) {// for all the feature point
double i=vect[num].i;
double j=vect[num].j;
local_node.clear();
for(int lnum = 0 ;lnum < vect.size(); lnum ++){
if(num==lnum){}
else{
int dist=abs(i-vect[lnum].i)+abs(j-vect[lnum].j);
node.dist=dist;
node.A.i=vect[lnum].i;
node.A.j=vect[lnum].j;
local_node.push_back(node);
}
}
}
return;
}