Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. class Shape {
  7. protected:
  8. long double a, b;
  9.  
  10. void Input() {
  11. long double a1, b1;
  12. cin >> a1 >> b1;
  13. a = a1; b = b1;
  14. }
  15. };
  16.  
  17. class Rectangle : protected Shape {
  18. public:
  19. long double getArea() {
  20. return a * b;
  21. }
  22.  
  23. void Input() {
  24. Shape::Input();
  25. }
  26. };
  27.  
  28. class Ellipse : protected Shape {
  29. public:
  30. long double getArea() {
  31. double pi = 355.0 / 113.0;
  32. return pi * a * b;
  33. }
  34.  
  35. void Input() {
  36. Shape::Input();
  37. }
  38. };
  39.  
  40. int main() {
  41. int n, m;
  42. cin >> n;
  43. Rectangle r;
  44. vector<Rectangle> rectangles;
  45.  
  46.  
  47. for (int i = 0; i < n; i++) {
  48. r.Input();
  49. rectangles.push_back(r);
  50. }
  51. long double max1 = 0;
  52.  
  53. for (int i = 0; i < n; i++) {
  54. if (max1 < rectangles[i].getArea()) {
  55. max1 = rectangles[i].getArea();
  56. }
  57. }
  58. cin >> m;
  59. Ellipse e;
  60. vector<Ellipse> ellipses;
  61.  
  62. for (int i = 0; i < m; i++) {
  63. e.Input();
  64. ellipses.push_back(e);
  65. }
  66. long double max2 = 0;
  67.  
  68. for (int i = 0; i < m; i++) {
  69. if (max2 < ellipses[i].getArea()) {
  70. max2 = ellipses[i].getArea();
  71. }
  72. }
  73.  
  74. if (max1 > max2) {
  75. cout << "Didžiausia figūra stačiakampis" << endl;
  76. cout << "Plotas " << max1;
  77. }
  78. else {
  79. cout << "Didžiausia figūra elipsė" << endl;
  80. cout << "Plotas " << max2;
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement