Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multi-Dimensional Arrays. Agenda Multiple-Level Arrays.

Similar presentations


Presentation on theme: "Multi-Dimensional Arrays. Agenda Multiple-Level Arrays."— Presentation transcript:

1 Multi-Dimensional Arrays

2 Agenda Multiple-Level Arrays.

3 Multiple-Level Arrays Chapter 16

4 Time Table PeriodMondayTuesdayWedThursFri 5BAC344AIBC233BStudent Help 6BAC344AIBC233BStudent Help 7IBC233AStudent Help IBC233AB 8IBC233AStudent Help IBC233AB 9IBC233CIBC233DIBC233CD 10IBC233CIBC233DIBC233CD 11BAC344A 12BAC344A

5 Arrays 01 Time-table-array. 05 Time-entry occurs 12 times. 10 Mon-Course-Code PIC X(8). 10 Tues-Course-Code PIC X(8). 10 Wed-Course-Code PIC X(8). 10 Thurs-Course-Code PIC X(8). 10 Fri-Course-Code PIC X(8).

6 Arrays 01 Time-table-array. 05 Time-entry occurs 5 times. 10 PRD1-Course-Code PIC X(8). 10 PRD2-Course-Code PIC X(8). 10 PRD3-Course-Code PIC X(8).... 10 PRD12-Course-Code PIC X(8).

7 Arrays 01 Time-table-array. 05 Day-in-week occurs 5 times. 10 Course-entry occurs 12 times. 15 Period-Number PIC 9(2). 15 Course-Code PIC X(8).

8 Time Table PeriodMondayTuesdayWedThursFri 5BAC344AIBC233BStudent Help 6BAC344AIBC233BStudent Help 7IBC233AStudent Help IBC233AB 8IBC233AStudent Help IBC233AB 9IBC233CIBC233DIBC233CD 10IBC233CIBC233DIBC233CD 11BAC344A 12BAC344A

9 Load a Multi-Dimensional Array Move ‘IBC233B’ to Course-Code (2, 5) Move 5 to Period-Number (2, 5) Move ‘IBC233B’ to Course-Code (2, 6) Move 6 to Period-Number (2, 6) Move ‘Student Help’ to Course-Code (2, 7) Move 7 to Period-Number (2, 7)

10 What is Cindy Doing on Tuesdays, Period 6? Display Course-Code (2, 6).

11 Processing a Multi-Dimensional Array Example counts the number of Student Help Time periods in a week. Perform 330-Count-Office Varying Day-Sub from 1 by 1 until Day-Sub > 5. 330-Count-Office. Perform 335-Count-Office-2 Varying Period-Sub from 1 by until Period-Sub > 12. 335-Count-Office-2. If Course-Code (Day-Sub, Period-Sub) = ‘Student Help’ Add 1 to office-count.

12 Processing a Multi-Dimensional Array Example counts the number of Student Help Time Periods in a week. Perform 430-Count-Office Varying Day-Sub from 1 by 1 until Day-Sub > 5 After Period-Sub from 1 by 1 until Period-Sub > 12. 430-Count-Office. If Course-Code (Day-Sub, Period-Sub) = ‘Student Help’ Add 1 to office-count.

13 Searching a Multi-Dimensional Array 01 Time-table-array. 05 Day-in-week occurs 5 times indexed by Day-Sub, 10 Course-entry occurs 12 times indexed by Period-Sub. 15 Period-Number PIC 9(2). 15 Course-Code PIC X(8). 77 Match-Found PIC X(3). 77 Day-FoundPIC 9(1). 77 Period-FoundPIC 9(2).

14 Searching a Multi-Dimensional Array Find the first occurrence of the course code IBC233AB. Move ‘No’ to Match-Found. Perform 500-Search-It Varying Day-Sub from 1 by 1 until Day-Sub > 5 or Match-Found = ‘Yes’. 500-Search-It. Set Period-Sub to 1. Search Course-Entry When Course-Code (Day-Sub, Period-Sub) = ‘IBC233AB’ Move Day-Sub to Day-Found Move Period-Sub to Period-Found Move ‘Yes’ to Match-Found END-Search.


Download ppt "Multi-Dimensional Arrays. Agenda Multiple-Level Arrays."

Similar presentations


Ads by Google