|
|
|
|
|
|
|
// Postcondition:
// IF strMonth is in strMonthAry
// found == TRUE && strMonthAry[index] contains strMonth
// ELSE
// found == FALSE && index == length
{
index = 0;
while (index < length &&
strcmp(strMonth, strMonthAry[index]) != 0)
// Invariant (prior to test):
// strMonth is not in strMonthAry[0..index-1]
// && 0 <= index <= length
index++;
found = (index < length);
} |
|
|
|
|
|
|
|
|
Because the BirthdayReminder program is so long, it is not repeated here. However, we guarantee that this function GetMonth was substituted for the one in Chapter 10 and the program was rerun. Notice that strMonthAry is an array of arrays, making it a two-dimensional array. We return to this subject in Chapter 13. |
|
|
|
|
|
|
|
|
Problem-Solving Case Study Exam Attendance |
|
|
|
|
|
|
|
|
Problem: You are the grader for a U.S. government class. The teacher has asked you to prepare two lists: students taking an exam and students who have missed it. The catch is that he wants the lists before the exam is over. You decide to write a program for your portable computer that takes each student's name as the student enters the exam room and prints the lists of absentees and attendees for your teacher. |
|
|
|
 |
|
|
|
|
A list of last names of the students in the class, ordered by social security number (file roster) |
|
|
|
 |
|
|
|
|
Each student's last name as he or she enters the room (standard input device) |
|
|
|
|
|