Hello World

Posted agnel-cynthia

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hello World相关的知识,希望对你有一定的参考价值。

#include <bits/stdc++.h>

using namespace std;

class point
{
public:
    int x, y, z;

    point(int x = 0, int y = 0, int z = 0): x(x), y(y), z(z)
    {
    }

    point operator - (const point &b) const
    {
        return point(x - b.x, y - b.y, z - b.z);
    }

    int operator * (const point &b) const
    {
        return x * b.x + y * b.y + z * b.z;
    }

    int sqr()
    {
        return *this * *this;
    }

    double len()
    {
        return sqrt(sqr());
    }
};

long long sqr(int x)
{
    return (long long) x * x;
}

int main()
{

    cout.setf(ios::fixed);
    cout.precision(10);
    int tt;
    cin >> tt;
    while (tt--)
    {
        point o, a, b;
        int r;
        cin >> o.x >> o.y >> o.z >> r;
        cin >> a.x >> a.y >> a.z;
        cin >> b.x >> b.y >> b.z;
        if ((a - b).sqr() == 0 || (o - a) * (b - a) <= 0 || (o - b) * (a - b) <= 0)
        {
            cout << (a - b).len() << "
";
        }
        else
        {
            double h = sqrt((o - a).sqr() - (double) sqr((o - a) * (b - a)) / (a - b).sqr());
            if (r <= h)
            {
                cout << (a - b).len() << "
";
            }
            else
            {
                double go_a = sqrt((o - a).sqr() - sqr(r));
                double go_b = sqrt((o - b).sqr() - sqr(r));
                double angle = atan2(sqrt((o - a).sqr() - h * h), h) + atan2(sqrt((o - b).sqr() - h * h), h) - atan2(go_a, r) - atan2(go_b, r);
                cout << angle * r + go_a + go_b << "
";
            }
        }
    }
    return 0;
}

 

以上是关于Hello World的主要内容,如果未能解决你的问题,请参考以下文章

Hello World代码

Hello World代码

怎么用maven写出hello world

第一行代码Hello,World!

hello.equals(hello)的代码值是多少?

Hello,World!