求一道c++题目

2024-12-03 07:24:02
推荐回答(1个)
回答1:

class CPoint
{
public:
    CPoint() : x(0), y(0)
    {}
    CPoint(int nx, int ny) : x(nx), y(ny)
    {}
    ~CPoint(){}
private:
    int x;
    int y
}
fun()
{
CPoint point1, point2, point3(1, 2), point4(3, 4);
// 求point1 和point2的距离
point1.x = 1;point1.y = 2;
point2.x = 3;point2.y = 4;
cout<<(point2.x - point1.x) * (point2.x - point1.x) + (point2.y - point1.y) * (point2.y - pint1.y)<// 求point3和point4的距离
cout<<(point4.x - point3.x) * (point4.x - point3.x) + (point4.y - point3.y) * (point4.y - pint3.y)<}