Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I previously asked this question and I felt like some codes are not understandable. So I want that code to be not complicated because it's
I previously asked this question and I felt like some codes are not understandable. So I want that code to be not complicated because it's been only a month after the course started so we haven't much to go through the complicated stuff... (only basics...) Oh and it's C programming! It will be so grateful if you could provide some explanation! Thank you so much :)
Part 2: Sorting and searching The farmer from before has been busy packing his vegetables into sealed boxes. Due to inexact measurements, the boxes wildly vary in weight. Luckily the grocery store has agreed to pay a fixed price per box, no matter how many vegetables are in there! Just as he's ready to ship them off, the delivery company informs him that their trucks have a weight limit! Each truck costs a different amount, so the farmer needs a way to quicky calculate the maximum number of boxes he can fit into a truck, given its weight capacity. Your input will be a file. On the first line will be a single positive integer n, greater than 0 and less than 2000. On the second line will be exactly 11 weights of different boxes in kg, with accuracy to at most the gram. Following this will be up to 100000 lines, each delimiting the maximum weight capacity of a truck. For each of these, you must output exactly one line, an integer of the number of the maximum number of boxes this truck can hold. Your program must be able to finish with the maximum sized input under a second. HINT: when searching, use a binary search, or else your program will be too slow for the larger inputs. Example input 1: 4 10.0 1.0 3.0 2.5 3.1 3.5 10.0 15.0 100.123 Example output 1: 5:.me Example input 2: 17 269.843 154.570 175.888 38.697 124.55 102.09 37.87 179.13 172.37 272.41 2.04 68.2 159.94 258.99 223.42 62.2 61.889 32.38 324.32 549.48 15422.01 837.91 381.73 403789.70 405.48 3900.31 671.01 492.38 Example output 2: 17 10 17 17 There will be no invalid input. All lines will be terminated with a \ , including the last one. Name your C source code file ex4q2 .cStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started