实验上机课的程序
来源:互联网 发布:儿童英语培训 知乎 编辑:程序博客网 时间:2024/05/16 05:59
#include"iostream"
#include"cmath"
using namespace std;
class Point
{
private:
double point_x;
double point_y;
public:
void show_point();
double back_x();
double back_y();
Point(double x,double y);
Point();
friend void calculate(Point point_1,Point point_2);
};
void Point::show_point()
{
cout<<"the coordinates of the point is "
<<"("<<point_x<<","<<point_y<<")"<<endl;
}
double Point::back_x()
{
return point_x;
}
double Point::back_y()
{
return point_y;
}
Point::Point(double x,double y)
{
point_x=x;
point_y=y;
}
Point::Point():point_x(0),point_y(0)
{
//Body intentionnally empty
}
void calculate(Point point_1,Point point_2)
{
cout<<"the distance between point_1 and point_2 is "<<(sqrt(pow(point_1.point_x-point_2.point_x,2)+pow(point_1.point_y-point_2.point_y,2)))<<endl;
}
int main()
{
double x1,y1,x2,y2;
cout<<"Please enter the coordinates of the first point"<<endl;
cin>>x1>>y1;
Point point_1(x1,y1),point_2;
point_1.show_point();
point_2.show_point();
x2=point_1.back_x();
y2=point_1.back_y();
cout<<"The coordinates of the first point is"<<"("<<x2<<","<<y2<<")"<<endl;
calculate(point_1,point_2);
cout<<"success"<<endl;
return 0;
}
- 实验上机课的程序
- 第一次C程序上机实验报告
- 第八次上机实验课
- 第九次上机课实验
- C++第1次上机实验-C++程序的编写和运行
- C++第2次上机实验-C++程序的编写和运行
- [C#]上机实验:类的使用
- 数据结构上机实验-二叉排序树的创建
- 我的第一次上机实验1-3
- 周巍的第一次上机实验
- 周巍的第二次上机实验
- 孙敬哲的C++上机实验1-2
- 我的第一次C++上机实验
- 孙敬哲的c++上机实验2-1
- 孙敬哲的c++上机实验2-2
- 孙敬哲的C++上机实验3-1
- 孙敬哲的C++上机实验3-2
- 我的第三次上机实验3-2
- B树结构的打印显示
- 初学电子知识
- php简明教程--笔记
- 第一篇日志。
- 加强计算机理论知识的再学习
- 实验上机课的程序
- QQ群78928780记录整理:90521人生话题-部分
- 急!急!
- 翻译的进度比想象中快
- QQ群78928780记录整理:90521花絮话题-部分
- QQ群78928780记录整理:90521技术话题-部分
- 轻松一下
- 深入浅出中关于宏缺点
- .net 3个timer