本文整理汇总了C++中point::print方法的典型用法代码示例。如果您正苦于以下问题:C++ point::print方法的具体用法?C++ point::print怎么用?C++ point::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类point
的用法示例。
在下文中一共展示了point::print方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: inOrder
void inOrder(point root){
if (root){
root->print();
inOrder(root->left);
inOrder(root->right);
}
return;
}
示例2: findConvexHull
void findConvexHull(vector<point> points , vector<point> &convexHull){
point minPoint = points[0];
for(int i=1;i<points.size();i++){
if((points[i].x < minPoint.x) || ((points[i].x ==minPoint.x) && (points[i].y < minPoint.y)))
minPoint = points[i];
}
cout<<"Base point is ";
basePoint = minPoint;
basePoint.print();
cout<<endl<<"----------------------"<<endl;
sort(points.begin() , points.end() , pointlt);
for(int i=0;i<points.size();i++){
points[i].print();
cout<<endl;
}
cout<<"-------------------------------"<<endl;
convexHull.push_back(points[0]);
int nPoints = points.size();
twoD curr_vec;// = AB(points[0] , points[1]);
point last_point;// = points[1];
//convexHull.push(points[1]);
int i = 1;
while(i < nPoints){
// curr_vec.print(); last_point.print(); cout<<endl;
if(convexHull.size()<2){
curr_vec = AB(points[0] , points[i]);
last_point = points[i];
convexHull.push_back(points[i]);
i++;
continue;
}
if(crossProduct(AB(last_point , points[i]) , curr_vec) > 0) { //all's well
convexHull.push_back(points[i]);
curr_vec = AB(last_point , points[i]);
last_point = points[i];
i++;
continue;
}
else{
convexHull.pop_back();
last_point = convexHull.back();
curr_vec = AB(convexHull[convexHull.size() -2] , convexHull[convexHull.size() - 1]);
continue;
}
}
}