本文整理汇总了C++中vp::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ vp::push_back方法的具体用法?C++ vp::push_back怎么用?C++ vp::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vp
的用法示例。
在下文中一共展示了vp::push_back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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";
}
}
示例3: main
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
cin >> N;
for (int i = 1; i <= N; i++) {
point temp;
cin >> temp.x >> temp.y;
P.push_back(temp);
}
point temp; temp.x = 0; temp.y = 0;
P.push_back(temp);
result = convex_hull(P);
cout << result.size() - 1;
return 0;
}
示例4: getInput
bool getInput()
{
//get input
int np;
scanf("%d ", &np);
if (fabs(0 - np) < EPS) return false;
double x, y;
REP(i, np)
{
scanf("%lf %lf ", &x, &y);
points.push_back(point(x, y));
}
示例5: add_point
void add_point(const Point& p) {
points_.push_back(p);
}