Boxes through a Tunnel

Sort by

recency

|

173 Discussions

|

  • + 0 comments

    Definitely a useful challenge for anyone preparing for C-based interviews on HackerRank. Telugu 365 Login

  • + 0 comments
    #include <stdio.h>
    #include <stdlib.h>
    #define MAX_HEIGHT 41
    
    typedef struct box{
    	/**
    	* Define three fields of type int: length, width and height
    	*/
        int length;
        int width;
        int height;
    } box;
    
     
    
    int get_volume(box b) {
    	/**
    	* Return the volume of the box
    	*/
        return (b.length * b.width * b.height);
    }
    
    int is_lower_than_max_height(box b) {
    	/**
    	* Return 1 if the box's height is lower than MAX_HEIGHT and 0 otherwise
    	*/
        if(b.height < 41) 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;
    }
    
  • + 0 comments

    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; }

  • + 0 comments

    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; }

  • + 0 comments

    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; } }