Practice Problem Part 2 & Practice Problem #2

2022. 6. 25. 00:10Coding - C

This is the progress I made, and since we got the efficiency and the ranking, we need to get the final value that the given capacity(200) can hold. So for each for loop, which will be ran 5 times since there is 5 values, if weight is less than capacity, which means if there is capacity to hold the weight, then that weight will be subtracted from the capacity, and the cnt will increase by its value. The weight and the value of the for loop will be in ranking order, as ranking[0] is the 4th value with the highest efficiency, and so on. 

 

For extra, if we are able to cut off some of the weight and accumulate that value, we will set the else if statement to give condition of if there is too much weight for the capacity to hold, then the count will be efficiency times the leftover capacity, then the capacity will be automatically set to 0.

'Coding - C' 카테고리의 다른 글

Pointers and Arrays  (0) 2022.07.02
Pointers  (0) 2022.07.02
Multi-Dimensional Array and Practice Problem: Part 1  (0) 2022.06.18
Recursive calls and Practice Problems  (0) 2022.06.04
First-dimensional Arrays  (0) 2022.05.27