📄 hw5-2.cpp
字号:
#include <iostream.h>
#include <math.h>
class Point {
float x, y;
public:
Point(float xx, float yy) {
x = xx; y = yy;
}
friend float Distance(Point &, Point &);
};
float Distance(Point &p1, Point &p2) {
float dx, dy;
dx = p2.x - p1.x;
dy = p2.y - p1.y;
return (float)sqrt(dx * dx + dy * dy);
}
void main() {
Point s(10, 10), t(25, 30);
cout << "两点之间距离为:" << Distance(s, t) << endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -