Let's think about the overall structure of our program. During this
discussion, we will assume that the rod is divided into exactly 20
segments.
After reading in the initial conditions, we need to initialize
oldtemps to reflect those conditions. Exactly what do we need to do?
Click here for the answer
Once oldtemps is initialized, we need to print out the histogram
showing its temperatures. It would be handy to create a helping
function to do this, and in fact we have done that for you. An
explanation of how to use this function is included in the homework
assignment.
Depending upon the number of time units specified by the user, we must
now repeatedly recalculate the temperatures of each of the segments.
For example, if the user wants 100 time units of simulation, we must
calculate the temperatures of each segment 100 times. What sort of
program structure does this suggest?
Click here for the answer
Now let's think about the body of this for loop. Each time
through the loop we must calculate new values for the oldtemps
array and then print it out. We can use the same function as above to
print out the temperatures, but how can we go about calculating the
new values?
Click here for the answer
Eric N. Eide
Hamlet Project
Department of Computer Science
University of Utah