📄 proj8_04.cpp
字号:
#include "iostream.h"
#include "math.h"
class Point
{
public:
Point(double i , double j)
{
x = i;
y = j;
}
void Getxy()
{
cout << "(" << x << "," << y << ")" << endl;
}
friend double Distance(Point a,Point b);
private:
double x , y;
};
double Distance(Point a , Point b)
{
double dx = a.x - b.x;
double dy = a.y - b.y;
return sqrt(dx * dx + dy * dy );
}
void main()
{
Point p1(3.0,4.0) , p2(6.0,8.0);
p1.Getxy();
p2.Getxy();
double d = Distance(p1,p2);
cout << "Distance:" << d << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -