#include int getBoxSidesArea(int l, int w, int h) { return (2*l*w + 2*w*h + 2*h*l); } int getSmallestSideArea(int l, int w, int h) { int smallest = (l * w); if((l * h) < smallest) { smallest = (l * h); } if((w * h) < smallest) { smallest = (w * h); } return smallest; } int getSmallestPerimeter(int l, int w, int h) { int use1, use2; if(l < w || l < h) { use1 = l; if(w < h) { use2 = w; } else { use2 = h; } } else { use1 = w; use2 = h; } return (use1 * 2) + (use2 * 2); } int getBoxArea(int l, int w, int h) { return l * w * h; } void part1() { printf("Part 1\n"); int l, w, h, result = 0; while(scanf("%dx%dx%d", &l, &w, &h) > 0) { result += getBoxSidesArea(l, w, h) + getSmallestSideArea(l, w, h); } printf("Square Feet Needed: %d\n", result); } void part2() { printf("Part 2\n"); int l, w, h, result = 0; while(scanf("%dx%dx%d", &l, &w, &h) > 0) { result += getSmallestPerimeter(l, w, h) + getBoxArea(l, w, h); } printf("Ribbon Length Needed: %d\n", result); } int main(int argc, char **argv) { int doPart = 1; if(argc > 1) { doPart = argv[1][0] - '0'; } if(doPart == 1) { part1(); } else { part2(); } return 0; }