Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include<iostream>
- #include <string>
- using namespace std;
- struct Circle
- {
- int x;
- int y;
- int radius;
- };
- struct BoundingBox
- {
- int bottomLeftAngleX;
- int bottomLeftAngleY;
- int topRightAngleX;
- int topRightAngleY;
- };
- Circle circleCoordinates(int x, int y, int radius);
- BoundingBox circleBoundingBox(Circle circle);
- void extractCircleBoundingBox(BoundingBox boundingBox);
- void main()
- {
- Circle sampleCircle = circleCoordinates(1, 2, 3); //create circle
- BoundingBox sampleBoundingBox = circleBoundingBox(sampleCircle); //get bounding box of the circle
- extractCircleBoundingBox(sampleBoundingBox); //print bounding box in specified format
- }
- Circle circleCoordinates(int x, int y, int radius) //creates circle
- {
- struct Circle circle;
- circle.x = x;
- circle.y = y;
- circle.radius = radius;
- return circle;
- }
- BoundingBox circleBoundingBox(Circle circle) //creates bounding box with parameter a circle
- {
- BoundingBox boundingBox;
- boundingBox.bottomLeftAngleX = circle.x - circle.radius;
- boundingBox.bottomLeftAngleY = circle.y - circle.radius;
- boundingBox.topRightAngleX = circle.x + circle.radius;
- boundingBox.topRightAngleY = circle.y + circle.radius;
- return boundingBox;
- }
- void extractCircleBoundingBox(BoundingBox boundingBox)
- {
- cout << "(" << boundingBox.bottomLeftAngleX << ", " << boundingBox.bottomLeftAngleY << ")"
- << "(" << boundingBox.topRightAngleX << ", " << boundingBox.topRightAngleY << ")";
- }
Advertisement
Add Comment
Please, Sign In to add comment