Phoenix_x

Untitled

Oct 19th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include<iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. struct Circle
  8. {
  9.     int x;
  10.     int y;
  11.     int radius;
  12. };
  13.  
  14. struct BoundingBox
  15. {
  16.     int bottomLeftAngleX;
  17.     int bottomLeftAngleY;
  18.     int topRightAngleX;
  19.     int topRightAngleY;
  20. };
  21.  
  22. Circle circleCoordinates(int x, int y, int radius);
  23. BoundingBox circleBoundingBox(Circle circle);
  24. void extractCircleBoundingBox(BoundingBox boundingBox);
  25.  
  26. void main()
  27. {
  28.     Circle sampleCircle = circleCoordinates(1, 2, 3); //create circle
  29.     BoundingBox sampleBoundingBox = circleBoundingBox(sampleCircle); //get bounding box of the circle
  30.     extractCircleBoundingBox(sampleBoundingBox); //print bounding box in specified format
  31. }
  32.  
  33. Circle circleCoordinates(int x, int y, int radius) //creates circle
  34. {
  35.     struct Circle circle;
  36.     circle.x = x;
  37.     circle.y = y;
  38.     circle.radius = radius;
  39.  
  40.     return circle;
  41. }
  42.  
  43. BoundingBox circleBoundingBox(Circle circle) //creates bounding box with parameter a circle
  44. {
  45.     BoundingBox boundingBox;
  46.  
  47.     boundingBox.bottomLeftAngleX = circle.x - circle.radius;
  48.     boundingBox.bottomLeftAngleY = circle.y - circle.radius;
  49.  
  50.     boundingBox.topRightAngleX = circle.x + circle.radius;
  51.     boundingBox.topRightAngleY = circle.y + circle.radius;
  52.  
  53.     return boundingBox;
  54. }
  55.  
  56. void extractCircleBoundingBox(BoundingBox boundingBox)
  57. {
  58.     cout << "(" << boundingBox.bottomLeftAngleX << ", " << boundingBox.bottomLeftAngleY << ")"
  59.         << "(" << boundingBox.topRightAngleX << ", " << boundingBox.topRightAngleY << ")";
  60. }
Advertisement
Add Comment
Please, Sign In to add comment