#include <stdio.h>
// write your code here......
typedef struct shape {
int x;
int y;
} shape_t;
typedef struct Rectangle rectangle_t;
typedef struct Rectangle {
int width;
int height;
shape_t point;
int (*get_area)(rectangle_t* obj);
} rectangle_t;
int GetRecArea(rectangle_t* obj) {
return obj->width * obj->height;
}
typedef struct Circle circle_t;
typedef struct Circle {
int radius;
shape_t point;
double (*get_area)(circle_t* obj);
} circle_t;
double GetCircleArea(circle_t* obj) {
return 3.14 * obj->radius * obj->radius;
}
typedef struct Square square_t;
typedef struct Square {
rectangle_t rec;
int (*get_area)(square_t* obj);
} square_t;
int GetSquareArea(square_t* obj) {
return obj->rec.width * obj->rec.width;
}
int main() {
int length, width, radius, side_length;
scanf("%d%d", &length, &width);
scanf("%d", &radius);
scanf("%d", &side_length);
// write your code here......
rectangle_t rec = {
.width = width,
.height = length,
.get_area = GetRecArea
};
printf("%d\n", rec.get_area(&rec));
circle_t cir = {
.radius = radius,
.get_area = GetCircleArea
};
printf("%g\n", cir.get_area(&cir));
square_t sq = {
.rec = {
.width = side_length,
.height = side_length,
.get_area = GetRecArea
},
.get_area = GetSquareArea
};
printf("%d\n", sq.get_area(&sq));
return 0;
}