• date post

14-Jan-2017
• Category

## Education

• view

3.121

0

Embed Size (px)

### Transcript of ΠΛΗ10 ΜΑΘΗΜΑ 2.5

• 10 2:

2.5:

• A. 1.

1. 2. 3. 4. 5.

2. 1. 2. 3.

3. 1. 2.

4. 1.

, 10, 2.5:

2

. 1.

1. 2. 3.

2. 1. 2.

3. 1. (Selection Sort)2. (Insertion Sort)3. (Bubble Sort)4. !

. 1. 2. 2 3. 4. 5. 6.

• A. 1. 1.

, 10, 2.5:

. !

: :

: xN

: , ... .

3

• A. 1. 2.

, 10, 2.5: 4

:

- .

( ) - : [1] [2] [3] ..... []

.

:ONOMA: ARRAY[1..N] OF - ;

• A. 1. 3.

, 10, 2.5: 5

:

10 10 :

:

:pin : ARRAY[1..10 ] OF INTEGER;

pin[1] pin[2] pin[3] pin[4]

pin[10]

• A. 1. 4.

, 10, 2.5: 6

5 P :

P[1],P[2],P[3],P[4],P[5] . , ..

:

75.

:P: ARRAY[1..5 ] OF INTEGER;

P[1]:=5;P[2]:=10;P[3]:=15;P[4]:=20;P[5]:=25;(P[1]+P[2]+P[3]+P[4]+P[5]);

• A. 1. 5.

, 10, 2.5: 7

10 . monodiastatos

N=10;

PIN: ARRAY[1..N] OF INTEGER;i: INTEGER;

i:=1 N (PIN[i]);

-

i:=1 N PIN[i]:=2*PIN[i];

-

i:=1 N (PIN[i]);

-

: .

• A. 1. 5.

, 10, 2.5: 8

, .

( ) -.

:

: (.. , ) (.. ,

, )

: .

• A. 2. 1.

, 10, 2.5: 9

:

x - .

( ) Mx - : [1,1],ONOMA[1,2],,ONOMA[1,N] [2,1],ONOMA[2,2],,ONOMA[2,N] [3,1],ONOMA[3,2],,ONOMA[3,N] ..... [M,1],ONOMA[M,2],,ONOMA[M,N]

.

:ONOMA: ARRAY[1.. ,1..N ] OF - ;

• A. 2. 2.

, 10, 2.5: 10

:

: pin[1,1], pin[1,2], pin[1,3] pin[2,1], pin[2,2], pin[2,3]

:

, , 6 , 6 :

:

:pin : ARRAY[1..2,1..3 ] OF INTEGER;

pin[1,1] pin[1,2] pin[1,3] pin[2,1]

pin[2,2] pin[2,3]

pin[1,1] pin[1,2] pin[1,3]

pin[2,1] pin[2,2] pin[2,3]

• A. 2. 3.

, 10, 2.5: 11

.

3x4 [i,j] i+j :

:

P: ARRAY[1..3,1..4] OF INTEGER;i,j: INTEGER;

i:=1 3 j:=1 4

P[i,j]:=i+j;-

-

1 2 3 4

1 2 3 4 5

2 3 4 5 6

3 4 5 6 7

: .

• A. 3. 1.

, 10, 2.5: 12

:

xxK - .

ONOMA[I,J,K] : 1 1 J N To 1 K R

:ONOMA: ARRAY[1..,1..N,1..R,1..] OF -

i:=1

j:=1 N

k:=1 R

...

• A. 3. 2.

, 10, 2.5: 13

.

.. :

....

:

...

.

:ONOMA: ARRAY[1.. ,1..N,1..R,1.. ] OF -

:ONOMA: ARRAY[1.. ,1..N,1..R,1.. ,1..S ] OF -

• A. 4. 1.

, 10, 2.5: 14

.

• A. 4. 1.

, 10, 2.5: 15

.

• . 1. 1.

, 10, 2.5: 16

PIN N min:

min:=PIN[1];

i:=2 N

(PIN[i] < min)

min:=PIN[i];

-

-

1: , PIN=[6,4,2,7,3].

2: , ( , )

3: .

• . 1. 2.

, 10, 2.5: 17

PIN N sum:

sum:=0;

i:=1 N

sum:=sum+pin[i];

-

1: , PIN=[6,4,2,7,3].

2: , ( , )

3: .

• . 1. 3.

, 10, 2.5: 18

:

i:=1 N

B[i]:=A[i];

-

1: , ( , )

2: : , C, . C C. ,,C.

• . 2. 1.

, 10, 2.5: 19

: PIN x. x PIN;

check:=FALSE; /* BOOLEAN */

i:=1 N

(x=PIN[i])

check:=TRUE;

-

-

1: , PIN=[6,4,2,7,3] , x=7.

2: , ( , )

3: .

• . 2. 2.

, 10, 2.5: 20

: PIN ( ) x. x PIN;check:=FALSE;

start:=1;

finish:=N;

(startPIN[middle])

start:=middle+1;

finish:=middle-1;

-

-

-

1: , PIN=[2,4,6,8,10,12,14,16,18,20] , x=8.

2: , PIN=[2,4,6,8,10,12,14,16,18,20] , x=15.

3: , ( , )

• . 3. 1. (Selection Sort)

, 10, 2.5: 21

: PIN. (SELECTION SORT). i:=1 N

/*

j=i+1N */

pos:=i;

j:=i+1 N

(PIN[j]

• . 3. 2. (Insertion Sort)

, 10, 2.5: 22

: PIN. (INSERTION SORT). i:=2 N

j:=i;

check:=FALSE;

j>=2 AND check=FALSE

(PIN[j]

• . 3. 3. (Bubble Sort)

, 10, 2.5: 23

: PIN. (BUBBLE SORT). i:=1 N

j:=N i+1 - -1

(PIN[j]

• . 3. 4.

, 10, 2.5: 24

! !

: (MergeSort) (QuickSort)

, .

• . 1:

, 10, 2.5:

( ) : 5 10

.

.

25

• . 2: 2

, 10, 2.5:

( ) : 5 10

.

.

26

• . 3:

, 10, 2.5:

( ) : 2 5

3 6 Mx

Mx . .

27

• . 4:

, 10, 2.5:

( ) : 2 5

xN . .

28

: .

.

• . 5:

, 10, 2.5:

( ) : 2 5

NxN ( ). ( C)

.

29

: .

.

• . 6:

, 10, 2.5:

( ) : 2 5

NxN ( ). ( C)

.

30

: .

.