daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Jan 17th, 2018 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. struct Point
  6. {
  7.     double x, y, z;
  8. };
  9.  
  10. struct Cone
  11. {
  12.     Point O;
  13.     double r, h;
  14. };
  15.  
  16. void InputPoint(Point *A);
  17. void PrintPoint(Point A);
  18. void InputCone(Cone *Figure);
  19. void PrintCone(Cone Figure);
  20. bool Check(Cone Figure, Point A);
  21.  
  22. void InputPoint(Point *A)
  23. {
  24.     cin >> (*A).x >> (*A).y >> (*A).z;
  25. }
  26.  
  27. void PrintPoint(Point A)
  28. {
  29.     cout << "(" << A.x << ", "<< A.y << ", " << A.z << ")";
  30. }
  31.  
  32. void InputCone(Cone *Figure)
  33. {
  34.     cout << "\n\nEnter the center: ";
  35.     cin >> (*Figure).O.x >> (*Figure).O.y >> (*Figure).O.z;
  36.     cout << "Enter r: ";
  37.     cin >> (*Figure).r;
  38.     cout << "Enter the height: ";
  39.     cin >> (*Figure).h;
  40. }
  41.  
  42. void PrintCone(Cone Figure)
  43. {
  44.     PrintPoint(Figure.O);
  45.     cout << "\nRadius: " << Figure.r << "\nCoordinats of Height: " << Figure.h;
  46. }
  47.  
  48. bool Check(Cone Figure, Point A)
  49. {
  50.     if ((A.z - Figure.O.z > 0) and (Figure.h + Figure.O.z - A.z > 0))
  51.     {
  52.         double radius = Figure.r * (A.z - Figure.O.z) / Figure.h;
  53.         if (sqrt((A.x - Figure.O.x) * (A.x - Figure.O.x) + (A.y - Figure.O.y) * (A.y - Figure.O.y)) < radius)
  54.             return true;
  55.     }
  56.     return false;
  57. }
  58.  
  59. int main()
  60. {
  61.     Point A;
  62.     cout << "Enter the searching point: ";
  63.     InputPoint(&A);
  64.     cout << "A: ";
  65.     PrintPoint(A);
  66.    
  67.     Cone Figure;
  68.     InputCone(&Figure);
  69.     cout << "\nCone:\n";
  70.     PrintCone(Figure);
  71.    
  72.     if (Check(Figure, A)) cout << "\nYes";
  73.     else cout << "\nNo";
  74.    
  75.     cout << endl;
  76.     return 0;
  77. }
RAW Paste Data
Top