Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- struct Point
- {
- double x, y, z;
- };
- struct Cone
- {
- Point O;
- double r, h;
- };
- void InputPoint(Point *A);
- void PrintPoint(Point A);
- void InputCone(Cone *Figure);
- void PrintCone(Cone Figure);
- bool Check(Cone Figure, Point A);
- void InputPoint(Point *A)
- {
- cin >> (*A).x >> (*A).y >> (*A).z;
- }
- void PrintPoint(Point A)
- {
- cout << "(" << A.x << ", "<< A.y << ", " << A.z << ")";
- }
- void InputCone(Cone *Figure)
- {
- cout << "\n\nEnter the center: ";
- cin >> (*Figure).O.x >> (*Figure).O.y >> (*Figure).O.z;
- cout << "Enter r: ";
- cin >> (*Figure).r;
- cout << "Enter the height: ";
- cin >> (*Figure).h;
- }
- void PrintCone(Cone Figure)
- {
- PrintPoint(Figure.O);
- cout << "\nRadius: " << Figure.r << "\nCoordinats of Height: " << Figure.h;
- }
- bool Check(Cone Figure, Point A)
- {
- if ((A.z - Figure.O.z > 0) and (Figure.h + Figure.O.z - A.z > 0))
- {
- double radius = Figure.r * (A.z - Figure.O.z) / Figure.h;
- if (sqrt((A.x - Figure.O.x) * (A.x - Figure.O.x) + (A.y - Figure.O.y) * (A.y - Figure.O.y)) < radius)
- return true;
- }
- return false;
- }
- int main()
- {
- Point A;
- cout << "Enter the searching point: ";
- InputPoint(&A);
- cout << "A: ";
- PrintPoint(A);
- Cone Figure;
- InputCone(&Figure);
- cout << "\nCone:\n";
- PrintCone(Figure);
- if (Check(Figure, A)) cout << "\nYes";
- else cout << "\nNo";
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement