| CSC 161 | Grinnell College | Fall, 2011 |
| Imperative Problem Solving and Data Structures | ||
The goal of this lab is to introduce arrays to students.
speed? You may want to try reasonably small errors (say
index = 8) as well as ridiculous indices (say index = 123456789). Explain
the results that you get.
Moving in Different Speeds
The following program, array-move.c, makes
the Scribbler move with certain speeds for certain times, which are in
the corresponding indices of their arrays. Explain how this program is
similar to and different from the program array-index.c from
the previous question.
numMoves, which tells the number of moves(it is now 8) to different numbers and see what happens.
Play a Song with the Help of an Array
Copy the program fragment array-notes.c, and use it to write a program which plays the song with 0.5 second notes.
Making a Reverse Movie
Write a program that tells the Scribbler to take and store 6 photos by turning in a circle, and showing them in reverse order. Taking the pictures and showing them should be done with two seperate loops. Below are some things you need to know in order to write this program:
This is how you declare a Picture:
Picture * pic;
This is how you take and store a Picture:
pic = rTakePicture();
This is how you show a Picture
rShowPicture (pic);
Note, however, that rShowPicture is a blocking call;
that is, when you call rShowPicture, the picture is displayed,
and subsequent processing is suspended until you close the picture's
window.
rDisplayPicure()When you can use
rDisplayPicture, the picture is displayed,
and subseqent processing continues.
You can make an array of Picture just like any other variable type.
When you have finished this lab, be sure to fill out its evaluation form in the "Lab Evaluation" section for CSC 161 on Pioneer Web.
This document is available on the World Wide Web as
http://www.walker.cs.grinnell.edu/courses/161.fa11/modules/module-arrays-functions/arraylab.shtml
|
created 19 July 2011 by Dilan Ustek last revised 18 September 2011 by Henry Walker |
|
| For more information, please contact Henry M. Walker at walker@cs.grinnell.edu. |