⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 友元 距离.txt

📁 最后声明
💻 TXT
字号:
#include<iostream> 
#include<math.h> 
using namespace std; 
class Point 
{ 
double x,y; 
public: 
Point(double a,double b) 
{ 
x=a;y=b; 
} 
friend double xdis(Point & a,Point & b); 
friend double ydis(Point & a,Point & b);
}; 
double xdis(Point & a,Point & b) 
{ 
return sqrt(a.x-b.x); 
} 
double ydis(Point & a,Point & b) 
{ 
return sqrt(a.y-b.y); 
} 
void main() 
{ 
Point A(1,1), B(2,2); 
cout<<"xdis is "<<xdis(A,B)<<endl; 
cout<<"ydis is "<<ydis(A,B)<<endl; 
} 



原版

#include<iostream> 
#include<math.h> 
using namespace std; 
class Point 
{ 
double x,y; 
public: 
Point(double a,double b) 
{ 
x=a;y=b; 
} 
friend double dis(Point & a,Point & b); 
}; 
double dis(Point & a,Point & b) 
{ 
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 
} 
void main() 
{ 
Point A(1,1), B(1,3); 
cout<<dis(A,B)<<endl; 
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -