multidimensional array n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Multidimensional Array: PowerPoint Presentation
Download Presentation
Multidimensional Array:

Loading in 2 Seconds...

play fullscreen
1 / 10

Multidimensional Array: - PowerPoint PPT Presentation


  • 113 Views
  • Uploaded on

Multidimensional Array:. อนันต์ ผลเพิ่ม Anan Phonphoem anan@cpe.ku.ac.th. Score[1]. 90. Score[2]. 75. Score[3]. 40. Score[4]. 67. Score[5]. 55. Score[6]. 30. One dimensional Array. Type ScoreArr = array [1..6] of integer ; var score: ScoreArr;. Election Score.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Multidimensional Array:' - oren-livingston


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
multidimensional array

Multidimensional Array:

อนันต์ ผลเพิ่ม

Anan Phonphoem

anan@cpe.ku.ac.th

one dimensional array

Score[1]

90

Score[2]

75

Score[3]

40

Score[4]

67

Score[5]

55

Score[6]

30

One dimensional Array

Type ScoreArr = array[1..6] of integer;

var score: ScoreArr;

election score
Election Score

Type ScoreArr = array[1..6] of integer;

var Score: ScoreArr;

Score

Candidate #

1

90

2

75

3

40

4

67

5

55

6

30

election 3 districts
Election: 3 districts

Type ScoreArr = array[1..6] of integer;

var scoreD1, scoreD2, scoreD3: ScoreArr;

Candidate #

ScoreD1

ScoreD2

ScoreD3

1

90

10

34

2

75

5

78

3

40

60

9

4

67

72

22

5

55

12

66

6

30

44

3

2 dimensional array

Score

1

90

10

34

2

75

5

78

3

40

60

9

4

67

72

22

5

55

12

66

6

30

44

3

2-dimensional array

ScoreD1

ScoreD2

ScoreD3

90

10

34

75

5

78

40

60

9

67

72

22

55

12

66

44

3

30

2 dimensional array1

Candidate #

District

2-dimensional array

Score

1

2

3

1

90

10

34

2

75

5

78

3

40

60

9

4

67

72

22

5

55

12

66

6

30

44

3

Score[candidate, district]

Score[1,1] =

Score[4,2] =

Score[5,3] =

2 dimensional array2
2-dimensional array

Score

1

2

3

1

90

10

34

2

75

5

78

3

40

60

9

4

67

72

22

5

55

12

66

6

30

44

3

Type

Score2Arr = array[1..6,1..3] of integer;

var

Score: Score2Arr;

accessing array elements
Accessing Array elements
  • Score[1,1] = 10
  • For I := 1 to 6 do

Readln(Score[I,1]);

  • For candidate := 1 to 6 do

For district := 1 to 3 do

Readln(Score[candidate, district]);

  • For district := 1 to 3 do

Writeln(Score[3,district]);

practice
Practice…
  • Write a program to find the winner of the election in each district
  • Write a program to find the winner of the election
  • Write an O-X game (Tic-Tac-Toe)
3 dimensional array

Movie Title: สุริโยไท

1

2

3

1

2

3

1

X

-

-

-

-

-

2

X

X

X

-

X

X

3

-

X

-

-

X

-

4

-

-

-

X

X

X

Midnight

8 PM

3-dimensional array

Seat[round, row, col]

Seat[Evening, 3, 1] = Available;

Seat[Midnight, 2, 4] = Taken;