└── Boxes through a tunnel /Boxes through a tunnel: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define MAX_HEIGHT 41 4 | struct box 5 | { 6 | /** 7 | * Define three fields of type int: length, width and height 8 | */ 9 | int length; 10 | int width; 11 | int height; 12 | }; 13 | 14 | typedef struct box box; 15 | 16 | int get_volume(box b) { 17 | /** 18 | * Return the volume of the box 19 | */ 20 | return b.length * b.width * b.height; 21 | } 22 | 23 | int is_lower_than_max_height(box b) { 24 | /** 25 | * Return 1 if the box's height is lower than MAX_HEIGHT and 0 otherwise 26 | */ 27 | if (b.height < MAX_HEIGHT) { 28 | return 1; 29 | } else { 30 | return 0; 31 | } 32 | } 33 | 34 | int main() 35 | { 36 | int n; 37 | scanf("%d", &n); 38 | box *boxes = malloc(n * sizeof(box)); 39 | for (int i = 0; i < n; i++) { 40 | scanf("%d%d%d", &boxes[i].length, &boxes[i].width, &boxes[i].height); 41 | } 42 | for (int i = 0; i < n; i++) { 43 | if (is_lower_than_max_height(boxes[i])) { 44 | printf("%d\n", get_volume(boxes[i])); 45 | } 46 | } 47 | return 0; 48 | } 49 | --------------------------------------------------------------------------------