You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

42 lines
707 B

#include <stdio.h>
int getBoxArea(int l, int w, int h) {
return (2*l*w + 2*w*h + 2*h*l);
}
int getSmallestSide(int l, int w, int h) {
if(l < w && l < h) {
return l;
}
if(w < l && w < h) {
return w;
}
return h;
}
void part1() {
printf("Part 1\n");
int floor = 0;
char str[100];
int l, w, h, result = 0;
while(scanf("%dx%dx%d", &l, &w, &h) > 0) {
result += getBoxArea(l, w, h) + getSmallestSide(l, w, h);
}
printf("Square Feet Needed: %d\n", result);
}
void part2() {
printf("Part 1\n");
}
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;
}