Презентация «Programming Logic and Design Seventh Edition»

Смотреть слайды в полном размере
Презентация «Programming Logic and Design Seventh Edition»

Вы можете ознакомиться с презентацией онлайн, просмотреть текст и слайды к ней, а также, в случае, если она вам подходит - скачать файл для редактирования или печати. Документ содержит 46 слайдов и доступен в формате ppt. Размер файла: 1.16 MB

Просмотреть и скачать

Pic.1
Programming Logic and Design Seventh Edition Chapter 6 Arrays
Programming Logic and Design Seventh Edition Chapter 6 Arrays
Pic.2
Objectives In this chapter, you will learn about: Storing data in arrays How an array can replace ne
Objectives In this chapter, you will learn about: Storing data in arrays How an array can replace nested decisions Using constants with arrays Searching an array for an exact match Using parallel …
Pic.3
Objectives (continued) Searching an array for a range match Remaining within array bounds Using a fo
Objectives (continued) Searching an array for a range match Remaining within array bounds Using a for loop to process arrays
Pic.4
How Arrays Occupy Computer Memory Array A series or list of variables in computer memory All variabl
How Arrays Occupy Computer Memory Array A series or list of variables in computer memory All variables share the same name Each variable has a different subscript Subscript (or index) Position number …
Pic.5
Each item has the same name and the same data type Each item has the same name and the same data typ
Each item has the same name and the same data type Each item has the same name and the same data type Element: an item in the array Array elements are contiguous in memory Size of the array: the …
Pic.6
How Arrays Occupy Computer Memory (continued)
How Arrays Occupy Computer Memory (continued)
Pic.7
How an Array Can Replace Nested Decisions Example: Human Resources Department Dependents report List
How an Array Can Replace Nested Decisions Example: Human Resources Department Dependents report List employees who have claimed zero through five dependents Assume no employee has more than five …
Pic.8
«Programming Logic and Design Seventh Edition», слайд 8
Pic.9
How an Array Can Replace Nested Decisions (continued) The array reduces the number of statements nee
How an Array Can Replace Nested Decisions (continued) The array reduces the number of statements needed Six dependent count accumulators are redefined as a single array Variable as a subscript to the …
Pic.10
«Programming Logic and Design Seventh Edition», слайд 10
Pic.11
«Programming Logic and Design Seventh Edition», слайд 11
Pic.12
How an Array Can Replace Nested Decisions (continued)
How an Array Can Replace Nested Decisions (continued)
Pic.13
«Programming Logic and Design Seventh Edition», слайд 13
Pic.14
How an Array Can Replace Nested Decisions (continued) Figure 6-7 Flowchart and pseudocode for Depend
How an Array Can Replace Nested Decisions (continued) Figure 6-7 Flowchart and pseudocode for Dependents report program (continued)
Pic.15
Using Constants with Arrays Use constants in several ways To hold the size of an array As the array
Using Constants with Arrays Use constants in several ways To hold the size of an array As the array element values As an array subscript
Pic.16
Using a Constant as the Size of an Array Avoid “magic numbers” (unnamed constants) Declare a named n
Using a Constant as the Size of an Array Avoid “magic numbers” (unnamed constants) Declare a named numeric constant to be used every time the array is accessed Make sure any subscript remains less …
Pic.17
Using Constants as Array Element Values Sometimes the values stored in arrays should be constants Ex
Using Constants as Array Element Values Sometimes the values stored in arrays should be constants Example string MONTH[12] = "January", "February", "March", …
Pic.18
Using a Constant as an Array Subscript Use a numeric constant as a subscript to an array Example Dec
Using a Constant as an Array Subscript Use a numeric constant as a subscript to an array Example Declare a named constant as: num INDIANA = 5 Display value with: output salesArray[INDIANA]
Pic.19
Searching an Array for an Exact Match Sometimes you must search through an entire array to find a va
Searching an Array for an Exact Match Sometimes you must search through an entire array to find a value Example: mail-order business Item numbers are three-digit, non-consecutive numbers Customer …
Pic.20
«Programming Logic and Design Seventh Edition», слайд 20
Pic.21
«Programming Logic and Design Seventh Edition», слайд 21
Pic.22
«Programming Logic and Design Seventh Edition», слайд 22
Pic.23
Searching an Array for an Exact Match (continued) Flag: a variable that indicates whether an event o
Searching an Array for an Exact Match (continued) Flag: a variable that indicates whether an event occurred Technique for searching an array Set a subscript variable to 0 to start at the first …
Pic.24
Using Parallel Arrays Example: mail-order business Two arrays, each with six elements Valid item num
Using Parallel Arrays Example: mail-order business Two arrays, each with six elements Valid item numbers Valid item prices Each price in the valid item price array is in the same position as the …
Pic.25
Using Parallel Arrays (continued)
Using Parallel Arrays (continued)
Pic.26
Using Parallel Arrays (continued) Use parallel arrays Two or more arrays contain related data A subs
Using Parallel Arrays (continued) Use parallel arrays Two or more arrays contain related data A subscript relates the arrays Elements at the same position in each array are logically related Indirect …
Pic.27
«Programming Logic and Design Seventh Edition», слайд 27
Pic.28
«Programming Logic and Design Seventh Edition», слайд 28
Pic.29
«Programming Logic and Design Seventh Edition», слайд 29
Pic.30
Improving Search Efficiency The program should stop searching the array when a match is found Set a
Improving Search Efficiency The program should stop searching the array when a match is found Set a variable to a specific value instead of letting normal processing set it Improves efficiency The …
Pic.31
«Programming Logic and Design Seventh Edition», слайд 31
Pic.32
Improving Search Efficiency (continued)
Improving Search Efficiency (continued)
Pic.33
Searching an Array for a Range Match Programmers may want to work with ranges of values in arrays, 1
Searching an Array for a Range Match Programmers may want to work with ranges of values in arrays, 1 through 5 or 20 through 30 Example: mail-order business Read the customer order data; determine …
Pic.34
Searching an Array for a Range Match (continued)
Searching an Array for a Range Match (continued)
Pic.35
Searching an Array for a Range Match (continued) Drawbacks of first approach Requires a very large a
Searching an Array for a Range Match (continued) Drawbacks of first approach Requires a very large array; uses a lot of memory Stores the same value repeatedly How do you know when you have enough …
Pic.36
Searching an Array for a Range Match (continued)
Searching an Array for a Range Match (continued)
Pic.37
«Programming Logic and Design Seventh Edition», слайд 37
Pic.38
Remaining within Array Bounds Every array has a finite size Number of elements in the array Number o
Remaining within Array Bounds Every array has a finite size Number of elements in the array Number of bytes in the array Arrays are composed of elements of the same data type Elements of the same …
Pic.39
Remaining within Array Bounds (continued)
Remaining within Array Bounds (continued)
Pic.40
Remaining within Array Bounds (continued) Program logic assumes every number entered by the user is
Remaining within Array Bounds (continued) Program logic assumes every number entered by the user is valid When an invalid subscript is used: Some languages stop execution and issue an error Other …
Pic.41
Using a for Loop to Process Arrays for loop: a single statement Initializes the loop control variabl
Using a for Loop to Process Arrays for loop: a single statement Initializes the loop control variable Compares it to a limit Alters it The for loop is especially convenient when working with arrays …
Pic.42
Using a for Loop to Process Arrays (continued)
Using a for Loop to Process Arrays (continued)
Pic.43
Using a for Loop to Process Arrays (continued)
Using a for Loop to Process Arrays (continued)
Pic.44
Summary Array: a named series or list of values in memory Same data type Different subscript Use a v
Summary Array: a named series or list of values in memory Same data type Different subscript Use a variable as a subscript to the array to replace multiple nested decisions Constants can be used to …
Pic.45
Summary (continued) Parallel arrays: each element in one array is associated with the element in a s
Summary (continued) Parallel arrays: each element in one array is associated with the element in a second array Elements have the same relative position For range comparisons, store either the low- …
Pic.46
Summary (continued) Access data in an array Use a subscript containing a value that accesses memory
Summary (continued) Access data in an array Use a subscript containing a value that accesses memory occupied by the array A subscript is out of bounds if it is not within the defined range of …


Скачать презентацию

Если вам понравился сайт и размещенные на нем материалы, пожалуйста, не забывайте поделиться этой страничкой в социальных сетях и с друзьями! Спасибо!