Due to the recommendation of many netizens, I finally made me calm down and see the book of "Analytical Algorithm Analysis and Programming"! Sure enough, it is in fact! Now use C issues in the process of reading the book, the original text is given by pascal! Many friends have given up this book because of this reason! It is a pity! Note: I have passed in BC5.0 in BC5.0!
Reproduction page 4
A heavy truck wants to pass 1 delete kilometers, the truck fuel consumption is 1 liter / km, the total power of the truck is 500
liter. Obviously the truck is installed, it can't be deserted. Therefore, the driver must try to establish several oil reservoirs along the way.
Make the truck smoothly through the desert, ask the driver how to build these reservoirs? How much gasoline should be stored for each reservoir point
Enable trucks to consume minimal petrol through the desert?
answer:
#include
#include
Void Oil_Lib ()
{
INT K; Float D, DL;
Float Oil [10], DIS [10];
Cout << "NO." << SETW (20) << "DISTANCE (K.M)" << SETW (90) << "OIL (L.) << endl;
K = 1;
D = 500;
DIS [1] = 500;
Oil [1] = 500;
Do {
K ;
D = 500 / (2 * k-1);
DIS [K] = D;
OIL [K] = OIL [K-1] 500;
WHILE (D <1000);
DIS [K] = 1000;
DL = 1000-DIS [k-1];
OIL [K] = DL * (2 * K 1) Oil [k-1];
For (int i = 0; i COUT << I << SETW (20) << (1000-DIS [K-I]) << SETW (90) << Oil [K-I] << ENDL; } Piggy Water Page 10 There is a thief when theft is found in a store: the Item value VI Yuan, heavy Wi pound, (1 <= i <= N), this VI and WI are integers. He hopes that the thing that is taken is, the better, but his backpack can only Pack the W pound thing (W is an integer). If you allow thieves to take a part of a certain item, what few things should be taken away, everything What is the weight? Question: #include operation hours. A set S for a set of unit time tasks, an arrangement of one scheduling of S, which specifies the execution order of these tasks. The first task in this scheduling begins at time 0, ending at the second task of time 15 At time 1, the end of time 2; ....... The inputs of the unit time task scheduling problem with time limit and fine on single processors are as follows: 1. Contains a collection of N unit time tasks S = F1, 2, ..., N75 2. n Taken the deadlines D1, I. . ..., D n, (1 3.21 non-negative rights (or fine) W:, ·, b ..., wno if the task I ends before time Di Fine W5 ;. It is required to find a scheduling of S, minimizing the total fines. Question: #include