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

📄 6_52.cpp

📁 C++程序设计技能百练随书配套光盘的源码
💻 CPP
字号:
#include<iostream.h>
#include<math.h>
class Point
{
public:
	void SetPoint();
	double Distance();
private:
	double X1,Y1,X2,Y2;
};

void Point::SetPoint()
{
	double x1,y1,x2,y2;
	cout<<"Input the first point's coordinate!"<<endl;
	cout<<"x1=";
	cin>>x1;
	cout<<"y1=";
	cin>>y1;
	cout<<endl;
	cout<<"Input the second point's coordinate!"<<endl;
	cout<<"x2=";
	cin>>x2;
	cout<<"y2=";
	cin>>y2;
	X1=x1;Y1=y1;X2=x2;Y2=y2;
}
double Point::Distance()
{
	double distance;
	distance=sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
	return distance;
}

void main()
{
	Point mypoint;
	mypoint.SetPoint();
	cout<<"The distance of the two points is:"<<mypoint.Distance();
	cout<<endl;
}

⌨️ 快捷键说明

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