Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- class Shape {
- protected:
- long double a, b;
- void Input() {
- long double a1, b1;
- cin >> a1 >> b1;
- a = a1; b = b1;
- }
- };
- class Rectangle : protected Shape {
- public:
- long double getArea() {
- return a * b;
- }
- void Input() {
- Shape::Input();
- }
- };
- class Ellipse : protected Shape {
- public:
- long double getArea() {
- double pi = 355.0 / 113.0;
- return pi * a * b;
- }
- void Input() {
- Shape::Input();
- }
- };
- int main() {
- int n, m;
- cin >> n;
- Rectangle r;
- vector<Rectangle> rectangles;
- for (int i = 0; i < n; i++) {
- r.Input();
- rectangles.push_back(r);
- }
- long double max1 = 0;
- for (int i = 0; i < n; i++) {
- if (max1 < rectangles[i].getArea()) {
- max1 = rectangles[i].getArea();
- }
- }
- cin >> m;
- Ellipse e;
- vector<Ellipse> ellipses;
- for (int i = 0; i < m; i++) {
- e.Input();
- ellipses.push_back(e);
- }
- long double max2 = 0;
- for (int i = 0; i < m; i++) {
- if (max2 < ellipses[i].getArea()) {
- max2 = ellipses[i].getArea();
- }
- }
- if (max1 > max2) {
- cout << "Didžiausia figūra stačiakampis" << endl;
- cout << "Plotas " << max1;
- }
- else {
- cout << "Didžiausia figūra elipsė" << endl;
- cout << "Plotas " << max2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement