Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Создать класс, описывающий точки на плоскости на плоскости.
- Определить расстояние от точки до начала координат. Создать класс - наследник,
- описывающий точки в пространстве. Определить расстояние между двумя точками.*/
- #include <iostream>
- #include <math.h>
- using namespace std;
- class point_on_the_plane{
- protected:
- float point_plane_x;
- float point_plane_y;
- float point_plane_z;
- //float point_spase_x, point_spase_y, point_spase_z;
- float rezult_0;
- public:
- point_on_the_plane(){
- point_plane_x = 0;
- point_plane_y = 0;
- point_plane_z = 0;
- }
- point_on_the_plane(float point_x, float point_y/*, float point_x1, float point_y1, float point_z1*/){
- point_plane_x = point_x;
- point_plane_y = point_y;
- point_plane_z = 0;
- /* point_spase_x = point_x1;
- point_spase_y = point_y1;
- point_spase_z = point_z1 */
- }
- float calculate_point_on_the_plane()
- {
- return static_cast<float>(sqrt(pow(point_plane_x,2)+pow(point_plane_y,2)));
- }
- ~point_on_the_plane(){}
- };
- class point_on_the_spase: public point_on_the_plane{
- protected:
- float point_space_x;
- float point_space_y;
- float point_space_z;
- public:
- point_on_the_spase(){}
- point_on_the_spase(float point_x, float point_y, float point_z, float x, float y)
- {
- point_plane_x = x;
- point_plane_y = y;
- point_space_x = point_x;
- point_space_y = point_y;
- point_space_z = point_z;
- }
- float get(){
- return (calculate_point_on_the_plane());
- }
- float calculate_point_of_the_spase()
- {
- // rezult_1 = sqrt(pow((point_space_x-point_plane_x),2)+pow((point_space_y-point_plane_y),2)+pow((point_spase_z-point_plane_z),2));
- return static_cast<float>(sqrt(pow((point_space_x-point_plane_x),2)+pow((point_space_y-point_plane_y),2)+pow((point_space_z-point_plane_z),2)));
- }
- ~point_on_the_spase(){}
- };
- int main()
- {
- float rezult = 0, rezult_0 = 0;
- float point_x = 0, point_y = 0/*, point_z = 0*/;
- float point_x1 = 0, point_y1 = 0, point_z1 = 0;
- cout << "Enter the coordinates of the point 'x': " << endl;
- cin >> point_x;
- cout << "Enter the coordinates of the point 'y': " << endl;
- cin >> point_y;
- // cout << "Enter the coordinates of the point 'z': " << endl;
- // cin >> point_z;
- cout << "Enter the coordinates of the point_1 'x': " << endl;
- cin >> point_x1;
- cout << "Enter the coordinates of the point_1 'y': " << endl;
- cin >> point_y1;
- cout << "Enter the coordinates of the point_1 'z': " << endl;
- cin >> point_z1;
- point_on_the_spase b(point_x1, point_y1, point_z1,point_x, point_y);
- rezult_0 = b.get();
- rezult = b.calculate_point_of_the_spase();
- cout <<"Otvet"<< endl;
- cout << "Result_0: " << endl ;
- cout << rezult_0 << endl;
- cout << "Result: " << endl ;
- cout << rezult << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement