[an error occurred while processing this directive]

CMSC201 Programming Hint

Overall approach to the problem

Think about the overall structure of your program. So expect to have three nested loops. What kind of loops -- for loops or while loops? For loops usually involve using an index variable as a counter which is incremented or decremented for each iteration until a special value is reached. A while loop is more general -- involving a condition which is checked as each iteration begins until it becomes true (e.g., a sentinel value was read). Or you can use a while loop with a TRUE condition, recognize when the loop should end inside the loop and force termination with a break.

Once you have the basic structure for your loops you can figure out how to keep track of the other items, such as the number of pixels in each image and their average values. Where should the variables for these two things be initialized? Where should they be updated? Where should this information be printed?

Try your program on the simplest data first. Know what the right answer should look like. Make up your own test data if necessary. When it is working for that, try it on more complicated data. [an error occurred while processing this directive]

Monday, 26-Feb-1996 19:47:35 EST