本文整理汇总了C++中vp::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ vp::clear方法的具体用法?C++ vp::clear怎么用?C++ vp::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vp
的用法示例。
在下文中一共展示了vp::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: andrewScan
void andrewScan(vp &polys,P *ps,int n) {
u.clear(); l.clear();
polys.clear();
if(n < 3) return ;
sort(ps,ps+n,cmpx);
u.pb(ps[0]);
u.pb(ps[1]);
l.pb(ps[n-1]);
l.pb(ps[n-2]);
for(int i = 2;i < n;i++) {
for(int j = u.size();j >= 2 && ccw(u[j-2],u[j-1],ps[i]) != 2;j--)
u.pop_back();
u.pb(ps[i]);
}
for(int i = n-3;i >= 0;i--) {
for(int j = l.size();j >= 2 && ccw(l[j-2],l[j-1],ps[i]) != 2;j--)
l.pop_back();
l.pb(ps[i]);
}
polys = l;
for(int i = 1;i < u.size()-1;i++) polys.pb(u[i]);
}
示例2: main
int main() {
int n, cases=0;
while(1) {
cin >> n;
// End of cases
if(n == 0) break;
// Init
points.clear();
int x, y;
// Read in points
for (int i = 0; i < n; ++i) {
cin >> x >> y;
points.push_back(point(x,y));
}
double convex_hull_area = area(CH(points));
// Complete the polygon, if necessary
if(!(points.back() == points.front()))
points.push_back(points.front());
double total_area = area(points);
double percent_diff = (convex_hull_area - total_area) / convex_hull_area * 100;
cout << "Tile #" << ++cases << endl;
cout << "Wasted Space = " << setprecision(2) << fixed << percent_diff << " " << '%' << endl << endl;
}
return 0;
}
示例3: main
int main(){
int N, n_ind, t, combs, n_morto;
point input;
double p_killed;
cin >> t;
while(t--){
cin >> n_ind;
N = n_ind;
combs = (N*(N-1)*(N-2))/6;
positions.clear();
while(n_ind--){
cin >> input.x >> input.y;
positions.push_back(input);
}
n_morto = 0;
for(vp::iterator ii = positions.begin(); ii != positions.end(); ++ii){
for(vp::iterator jj = ii+1; jj != positions.end(); ++jj){
for(vp::iterator kk = jj+1; kk != positions.end(); ++kk){
n_morto += calc_morto(ii,jj,kk);
}
}
}
p_killed = ((double)n_morto)/(combs * ((positions.size()-3)));
cout << setprecision(8) << p_killed << "\n";
}
}