5.7

发布时间 2023-05-07 21:08:13作者: 张佳木

#include <iostream>

using namespace std;

#include<cmath>

#include"time_user.h"

class point

{

private:

    int x, y, z;

public:

    void set()

    {

        cin >> x >> y >> z;

    }

    void out()

    {

        cout << "x: " << x << " y: " << y << " z " << endl;

    }

    int xget()

    {

        return x;

    }

    int yget()

    {

        return y;

    }

    int zget()

    {

        return z;

    }

};

float d(point& p)

{

    return sqrt(p.xget() * p.xget() + p.yget() * p.yget() + p.zget() * p.zget());

}

int main()

{

    point p1;

    p1.set();

    p1.out();

    cout << "到原点的距离:" << d(p1) << endl;

}