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.
#include<stdio.h>#include<stdlib.h>#define MAX_HEIGHT 41structbox{/** * Define three fields of type int: length, width and height */intlength;intwidth;intheight;};typedefstructboxbox;intget_volume(boxb){/** * Return the volume of the box */returnb.length*b.width*b.height;}intis_lower_than_max_height(boxb){/** * Return 1 if the box's height is lower than MAX_HEIGHT and 0 otherwise */if(b.height<MAX_HEIGHT){return1;}else{return0;}}intmain(){intn;scanf("%d",&n);box*boxes=malloc(n*sizeof(box));for(inti=0;i<n;i++){scanf("%d%d%d",&boxes[i].length,&boxes[i].width,&boxes[i].height);}for(inti=0;i<n;i++){if(is_lower_than_max_height(boxes[i])){printf("%d\n",get_volume(boxes[i]));}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Boxes through a Tunnel
You are viewing a single comment's thread. Return to all comments →