Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Technique
Topic 7 Advanced Data Types
Chapter Topics
8.1
8.2
8.3
8.4
8.5
8.6
Array Basics
Sequentially Searching an Array later topic
Processing the Contents of an Array
Parallel Arrays
Two-Dimensional Arrays
Arrays of Three or More Dimension
numbers[0]
numbers[1]
numbers[2]
numbers[3]
numbers[4]
=
=
=
=
=
20
30
40
50
60
20 30 40 50 60
5
20 30 40 50 60
6
Program 8-3
input
Input hours[index]
End For
For index = 0 To SIZE 1
Display hours[index]
display
End For
7
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
7 -- Advanced Data Types
Program Output
The average of the array elements is 5.3
10
total
average
11
12
If the element is greater than the highest value, that value is then
the assigned to the highest variable
If the element is less than the lowest value, that value is then the
assigned to the lowest variable
13
Program Output
The highest value in the array is 12
14
15
Program Output
17
firstArray
18
secondArray
0 100
100
200
200
300
400
300
400
500
500
30
10
19
Program Output
20
array
arraySize
SIZE
sum
30
total
21
22
In The
Spotlight
Using Parallel
Arrays (p316)
23
24
26
25
25
26
30
Input values[x][y][z]
End For
End For
End For
27
Chapter Topics
12.1 Introduction
12.2 Character-by-Character Text Processing
28
12. 1 Introduction
29
Chapter 6 Functions
Program 12-2
Module main()
Declare String name = Jacob
Declare Integer index
For index = 0 to length(name) - 1
Display name[index]
End For
End Module
Program Output
J
a
c
o
b
30
Can be modified:
Declare String str = "Coffee"
str[0] = "T"
Displays Toffee
Display str
Can be tested:
In The
Spotlight
Validating a
Password
(p482)
31
32
Program Output
Enter a Sentence.
Ms. Jones will arrive TODAY! [Enter]
That string has 7 uppercase letters.
33
Insert example
Declare String str = "New City"
insert(str, 4, "York ")
Display str // displays New York City
N e w
C i t y
Y o r k
N e w
35
Y o r k
C i t y
Delete example
Declare String str = "I ate 1000 blueberries!"
delete(str, 8, 9)
Display str // displays I ate 10 blueberries!
a t e
1 0 0 0
b l u e b e r r i e s !
0 0
I
36
a t e
1 0
b l u e b e r r i e s !