-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboxtunnel.c
47 lines (41 loc) · 877 Bytes
/
boxtunnel.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <stdlib.h>
#define MAX_HEIGHT 41
#define MAX_HEIGHT 41
struct box
{
int length , width , height;
};
typedef struct box box;
int get_volume(box b) {
/**
* Return the volume of the box
*/
int volume = b.length * b.width * b.height;
return volume;
}
int is_lower_than_max_height(struct box b) {
/**
* Return 1 if the box's height is lower than MAX_HEIGHT and 0 otherwise
*/
if(b.height < MAX_HEIGHT){
return 1;
} else {
return 0;
}
}
int main()
{
int n;
scanf("%d", &n);
box *boxes = malloc(n * sizeof(box));
for (int i = 0; i < n; i++) {
scanf("%d%d%d", &boxes[i].length, &boxes[i].width, &boxes[i].height);
}
for (int i = 0; i < n; i++) {
if (is_lower_than_max_height(boxes[i])) {
printf("%d\n", get_volume(boxes[i]));
}
}
return 0;
}