Simple program with my little initiative (code+explanation required)
I'm looking for someone who woudl be keen to guide me and explain to me how to write this program in ANSI C.
I'm not looking for some crib, mainly I would like to understand the code. So maybe some code with additional comments ?
In order not to look like look like a shirker, I'm keen to give you some personal suggestion about algorhytm.
Unfortunately, currently I'm not capable of spending any money on my personal project, so disinterested people are required.
Ok, here's the task.
Workers at the office have to visit their clients constanstly. The office policy is very enviromently friendly,
that is why the use only electric engined cars. Unfortunately cars they're using are not sufficient, nor have long
range without recharging. Additionaly, the office require from it's workers to have obligatory pause at work. Due to
this unique regulations, workers have to stop their cars and lodge in roadside motels EVERY TIME their cars run out of juice.
Write the program, which will help the worker to plan his journey, so that he won't stop at the motels unnecessarily.
Most efficient solutions required (less stops means less motels, ergo less expenses).
Program has to detect situation in which motels are too far away from each other, in which case it should
display some massage, for instance: ERROR !
Program will be given certain amount of kilometres to cover (N) on certain route,
range of electric car which could be exploit per ONE DAY (K) and (M) number of motels which are
available on the journey.
We assume that in m- lines there will be given distances between certain motels from the start of the journey.
We assume that distances are represented by integral numbers.
Distances between each motels will be ordered by size (number of kilometres), from the shortest distance to the longest.
Program is meant to display on OUTPUT minimal number of stops, which is needed to cover the distance which is received by program
at the beggining. If journey with specified paramateres will not live up to given requirements, program should display message
for instance WRONG SPECIFICATION !. We assume that at the beggining the batteries in the car are fully charged up !
Here's my IDEA ! ALGORYTHM !
Let's put distances between motels to the array. Then use some if statements to check if there's is enough distance to cover by the vehicle to reach destination of next motel.
I've have some code, but I've only manage to declare variables and did something strange with if().
Could you please, help me out with this ?
I would like to understand the code, so I'm not expecting only pure code without comments.
If you're keen to help me, contact me via e-mail: panzyciaismierci1(at)interia.pl
It's quite important not to publicate any solution in this thread, cause it will simply ruin my anonymous and my academic teacher would persumably kill me ;)