本文整理汇总了C++中P类的典型用法代码示例。如果您正苦于以下问题:C++ P类的具体用法?C++ P怎么用?C++ P使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了P类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
st.eat();
scanf( "%lf", &vp );
cur.eat();
scanf( "%lf%lf", &v, &r );
R = st.mag();
o = vp / R;
s = ang( st );
t = ang( cur );
Q = t - s;
while ( Q < -EPS ) Q += 2 * PI;
double up = 1e9, lo = 0;
while ( up > lo + 1e-10 ) {
double mid = (up + lo) / 2.0;
double ang = s + o * mid;
P p = P( R * cos(ang), R * sin(ang) );
double d = dist( p, cur );
if ( d < mid * v + EPS ) {
up = mid;
} else {
lo = mid;
}
}
printf( "%.9f\n", up);
return 0;
}
示例2: main
int main() {
int T;
scanf("%d", &T);
while (T--) {
double x1, y1, x2, y2, x3, y3;
scanf("%lf%lf", &x1, &y1);
scanf("%lf%lf", &x2, &y2);
scanf("%lf%lf", &x3, &y3);
const P p = center(P(x1, y1), P(x2, y2), P(x3, y3));
printf("%.3f %.3f %.3f\n", p.real(), p.imag(), abs(p-P(x1, y1)));
}
return 0;
}
示例3: solve
double solve()
{
u.read();v.read();
int k1,k2;
k1=mid((u-v).angle());
k2=mid((v-u).angle());
double t1=(u-v)*(p[k1]-v);
double t2=(u-v)*(p[k2]-v);
if(t1*t2>-eps)return 0.0;
double s1,s2;
P a,b;
s1=s2=0.0;
a=calc(k1,k2,s1,s2);
b=calc(k2,k1,s2,s1);
s1+=a*b;
s2+=b*a;
return min(s1,s2)/2.0;
}
示例4: switch
void PlayerInfo::onReceiveCommand(int32_t clientId, sf::Packet& packet)
{
if (clientId != this->clientId) return;
int16_t command;
packet >> command;
switch(command)
{
case CMD_UPDATE_CREW_POSITION:
{
int32_t position;
bool active;
packet >> position >> active;
crew_position[position] = active;
if (isMainScreen())
main_screen_control = false;
if (active && mySpaceship)
{
int main_screen_control_cnt = 0;
foreach(PlayerInfo, i, playerInfoList)
{
if (i->ship_id == mySpaceship->getMultiplayerId() && i->main_screen_control)
main_screen_control_cnt++;
}
if (main_screen_control_cnt == 0)
main_screen_control = true;
}
}
break;
case CMD_UPDATE_SHIP_ID:
packet >> ship_id;
break;
case CMD_UPDATE_MAIN_SCREEN_CONTROL:
packet >> main_screen_control;
break;
}
示例5: _distance
double _distance(const P& lhs, const P& rhs)
{
const P d = lhs - rhs;
return std::sqrt(d.x() * d.x() + d.y() * d.y());
}
示例6: toString
const std::string toString() const {
std::stringstream ss;
ss << "Point(" << myPoint.toString() << ")";
return ss.str();
}
示例7: translate
const std::shared_ptr<const ConvexCCWPolygon> translate(P p) const {
return std::shared_ptr<const ConvexCCWPolygon>(
new Point(P(myPoint.gX() + p.gX(), myPoint.gY() + p.gY())));
}
示例8: while
main()
{
int n,l;
while(1)
{
q1=_q[0],q2=_q[1];
heap.n=1;
test.set();
test.get();
scanf("%d",&n);
test.ball=n;
/*open(test);
node=20;
while(heap.n>1 && heap.n<9000 && node--)
open(heap.exmin());*/
best.set();
best.score=2147483647;
// Greedy Search
/*while(test.num>0)
{
best.set();
best.score=2147483647;
if(best.pn>0)
{
test.add(best.path[0].x,best.path[0].y);
printf("%d %d\n",best.path[0].x+1,best.path[0].y+1);
}*/
tp[5]=test;
dfs(5,0,0);
//}
//----------------------------------------------------------------
best.print();
}
}
示例9: next_permutation
void next_permutation(){
p.rotate(1);
int i=1;
while (++count[i] > i){
count[i++] = 0;
p.rotate( i );
}
}
示例10: restore
void restore() {
switch (u8.type) {
case Variant::U8: return u8.restore();
case Variant::U16: return u16.restore();
case Variant::U32: return u32.restore();
case Variant::U64: return u64.restore();
case Variant::U128: return u128.restore();
default: SYSLOG("patcher @ unsupported patch type %d, cannot restore", static_cast<int>(u8.type));
}
}
示例11: main
int main() {
int m, n, k;
int isUp = -1;
cin >> m >> n >> k;
p_m.totalNums = m;
p_n.totalNums = n;
for (int i=0; i<k; i++) {
double tmp;
cin >> tmp;
double pm = p_m.add(tmp);
double pn = p_n.add(tmp);
if (i+1 >= n) {
if (pm > pn && isUp != 1) {
isUp = 1;
cout << "BUY ON DAY " << i+1 << endl;
} else if (pm < pn && isUp != 0) {
isUp = 0;
cout << "SELL ON DAY " << i+1 << endl;
}
}
}
return 0;
}
示例12: main
int main()
{
sf("%d%d%d%d",&xa,&ya,&xb,&yb);
sf("%d",&n);
ren[1].x=xa;ren[1].y=ya;
ren[2].x=xb;ren[2].y=ya;
ren[3].x=xa;ren[3].y=yb;
ren[4].x=xb;ren[4].y=yb;
k=4;
for (i=min(ya,yb)+1;i<=max(ya,yb)-1;i++)
{
k++;
ren[k].x=xa;ren[k].y=i;
k++;
ren[k].x=xb;ren[k].y=i;
}
for (i=min(xa,xb)+1;i<=max(xa,xb)-1;i++)
{
k++;
ren[k].x=i;ren[k].y=ya;
k++;
ren[k].x=i;ren[k].y=yb;
}
for (i=1;i<=n;i++)
{
dian.input();
sf("%d",&r);
for (j=1;j<=k;j++)
if (dst(dian,ren[j])<=r)
ff[j]=1;
}
for (i=1;i<=k;i++)
if (!ff[i])
m++;
cout<<m<<endl;
return 0;
}
示例13: input
void input()
{
s.input();e.input();
}
示例14: print
void print() {
cerr << p.real() << " " << p.imag() << " " << r << endl;
}
示例15: scanf
const C &input() {
mid.input();
scanf("%lf", &r);
return *this;
}