Advertisement
_egorka_

point

Nov 12th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. /*Создать класс, описывающий точки на плоскости на плоскости.
  2. Определить расстояние от точки до начала координат. Создать класс - наследник,
  3. описывающий точки в пространстве. Определить расстояние между двумя точками.*/
  4.  
  5. #include <iostream>
  6. #include <math.h>
  7. using namespace std;
  8.  
  9. class point_on_the_plane{
  10. protected:
  11. float point_plane_x;
  12. float point_plane_y;
  13. float point_plane_z;
  14. //float point_spase_x, point_spase_y, point_spase_z;
  15. float rezult_0;
  16. public:
  17. point_on_the_plane(){
  18. point_plane_x = 0;
  19. point_plane_y = 0;
  20. point_plane_z = 0;
  21. }
  22. point_on_the_plane(float point_x, float point_y/*, float point_x1, float point_y1, float point_z1*/){
  23. point_plane_x = point_x;
  24. point_plane_y = point_y;
  25. point_plane_z = 0;
  26. /* point_spase_x = point_x1;
  27. point_spase_y = point_y1;
  28. point_spase_z = point_z1 */
  29.  
  30. }
  31. float calculate_point_on_the_plane()
  32. {
  33.  
  34. return static_cast<float>(sqrt(pow(point_plane_x,2)+pow(point_plane_y,2)));
  35. }
  36.  
  37. ~point_on_the_plane(){}
  38. };
  39. class point_on_the_spase: public point_on_the_plane{
  40. protected:
  41. float point_space_x;
  42. float point_space_y;
  43. float point_space_z;
  44.  
  45. public:
  46.  
  47. point_on_the_spase(){}
  48. point_on_the_spase(float point_x, float point_y, float point_z, float x, float y)
  49. {
  50. point_plane_x = x;
  51. point_plane_y = y;
  52. point_space_x = point_x;
  53. point_space_y = point_y;
  54. point_space_z = point_z;
  55.  
  56. }
  57.  
  58. float get(){
  59. return (calculate_point_on_the_plane());
  60. }
  61.  
  62. float calculate_point_of_the_spase()
  63. {
  64. // 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));
  65. 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)));
  66. }
  67. ~point_on_the_spase(){}
  68. };
  69.  
  70.  
  71. int main()
  72. {
  73. float rezult = 0, rezult_0 = 0;
  74. float point_x = 0, point_y = 0/*, point_z = 0*/;
  75. float point_x1 = 0, point_y1 = 0, point_z1 = 0;
  76.  
  77. cout << "Enter the coordinates of the point 'x': " << endl;
  78. cin >> point_x;
  79.  
  80. cout << "Enter the coordinates of the point 'y': " << endl;
  81. cin >> point_y;
  82. // cout << "Enter the coordinates of the point 'z': " << endl;
  83. // cin >> point_z;
  84.  
  85. cout << "Enter the coordinates of the point_1 'x': " << endl;
  86. cin >> point_x1;
  87. cout << "Enter the coordinates of the point_1 'y': " << endl;
  88. cin >> point_y1;
  89. cout << "Enter the coordinates of the point_1 'z': " << endl;
  90. cin >> point_z1;
  91.  
  92. point_on_the_spase b(point_x1, point_y1, point_z1,point_x, point_y);
  93.  
  94. rezult_0 = b.get();
  95. rezult = b.calculate_point_of_the_spase();
  96.  
  97. cout <<"Otvet"<< endl;
  98. cout << "Result_0: " << endl ;
  99. cout << rezult_0 << endl;
  100.  
  101. cout << "Result: " << endl ;
  102. cout << rezult << endl;
  103. return 0;
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement