We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Boxes through a Tunnel
Boxes through a Tunnel
Sort by
recency
|
173 Discussions
|
Please Login in order to post a comment
Definitely a useful challenge for anyone preparing for C-based interviews on HackerRank. Telugu 365 Login
include
include
define MAX_HEIGHT 41
struct box { int length; int width; int height; };
typedef struct box box;
int get_volume(box b) { return b.length*b.width*b.height; }
int is_lower_than_max_height(box b) { if(b.height<41) return 1; 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; }
25k-0580 struct box { int height; int width; int length; };
typedef struct box box;
int get_volume(box b) { return b.height * b.length * b.width; }
int is_lower_than_max_height(box b) { if(b.height < MAX_HEIGHT) return 1; else return 0; }
K250599 solution
struct box { int length; int width; int height; };
typedef struct box box;
int get_volume(box b) { int volume = b.length*b.width*b.height; return volume; }
int is_lower_than_max_height(box b) { if (b.height<41) { return 1; } else { return 0; } }