Программирование на языке Паскаль учебное пособие


119 downloads 5K Views 719KB Size

Recommend Stories

Empty story

Idea Transcript


. .

«

»

2014 1

004.43 32.973-018 87

: . .

, . . .,

,

-

; , . . ., . . .,

. .

«

-

»

. . : , 2014. – 168 .

87 . .

. –

:

/

». , . Pascal, . ,

-

. ,

,

-

, . ,

. Borland Pascal for

Windows, (Free Pascal, Pascal ABC). , . 004.43 32.973-018

© ©

. ., 2014 , 2014 2

-

................................................................................. 4 ...................................................................................... 12 ..................................................................................... 13 ( ) ................................................................ 15 ................................................................................................ 16 ............................................................................................. 18 ........................................................................................... 20 ............................................................................. 21 .............................................................................................. 23 .................................................................... 24 ....................................................... 26 ........................................................... 26 ....................................................................... 29 . ........................ 31 ................................................................................................ 41 ................................................................................................. 42 ............................................................................................... 44 ............................................................... 44 ..................................................................... 45 .............................................................................. 48 ....................................................................................... 49 ....................................................................................... 53 .................................................................................................... 54 ................................................................................................ 55 ..................................................................................... 55 ................................................................................... 65 ...................................................................................................... 70 .......................................................................... 71 ..................................................................... 72 ...................................................................... 79 ......................................................................... 88 ....................................................................................... 95 ........................................................................................................ 96 ......................................................................................................... 134 1. ................................................... 141 2. .......................................................... 155 3. ................................................... 161

3

,

,

. ,

,

.

. ,

-

(

),

-



,

,

-

,

-

, e-mail),

-

, . ( , ,

,

,

,

,

.

-

(

,

). .

-

,

.

– ,

,

.

.

,

,

-

,

-

, ,

,

.

,

. ,

« », «

», 4

», «

», «

-

,

. , .

,

,

,

.

,

-

. ,

,

,

,

-

. .

.

, ,

,

.

,

-

,

. ,

,

,

,

. –

,

.

: ) –

( –

,



. , ,

,

:

5

-

,

-

,

.

,

-

.

-

. ,

? .

.

6

:

-

– , . .



,



,

. –

.

, .

,

,

-

,

-

.

: ,

,

-

,

. .

,

,

.

.

,

, -

.

, -

.

-

,

. ,

,

,

.

-

. ,

-

. –

,

,

,

. :









. ,

,

.

7

,

, C, C++, Java, JavaScript, PHP.

. (FORTRAN, FORmula TRANslator –

-

)–

-

.

, , .

1954–1956 IBM

.

.

(

)

IBM 704. ,

,



,

,

,

IBM 704 ». 1956 .

-

II

.

1962 ,

-IV .

-

.

(

1962

)

(ASA).

,

-

.

-II

-IV,

,

-

.

(

-77), .

8

(ALGOL, ALGOrithmic Language –

)–

-

, . ,

, ,

. .

1959

.

.

.

1960

, –

.

IFIP (

-

)

-

1966

,

-

68. ,

.

,

-

,

,

. ,

. (COBOL, COmmon Business Oriented Language –

-

)–

,

, .

, .

9

-

IBM

1959

. (LISP, LISt Processing – 50-

.

) –

. .

-

. (APL, A Programming Language – 1961

IBM

)–

.

.

,

. (Basic – )– .

1965 .

-

.

Basic (

)

-



,

,

.

-

,

-

.

, .

.

-

,

. /1 (PL/1, Programming Language One – )–

1963–1966

IBM. , –

,

,

,

.

10

,

,

. /1

.

(Pascal) –

1968

.

,

.

(Ada) –

,

, .

-

, .

50

,

-

« .

.

»

«

,

»,

.

«

» ,

.

, :

,

,

-

,

.

. , 1975

.

,

1979 ,

1980 .

11

,

, -

, ,

70,

,

, ,

,

. ,

-

,

.

, . «

»

-

.

,

1983

-

,

-

,

.

80Borland Internation-

al,

.

80-

,

-

,

-

,

. .

1992 :

Turbo Pascal 7.0

Borland Pascal 7.0. (

)

-

. : , ( ), ,

; 12

,

-

,

-

;

, .

,

,

;

,

,

,

,

-

;

; ;



-

; .

– . –

,

.

13

-

: ; ; . 26 a r

s

b t

c

d

u

v

e w

f

g

x

y

:

h

i

j

k

l

m

n

o

p

q

z . _. -

. – 1

2

3

4

5

6

7

– 8

9

: 0





,

-

:

+

^ (

*

#

/

@

<

&

>

$

=



.

,

; : () [] {}

14

)

(

) –

,

. ,

,

, :

,

,

. . , :

And

Record

Array

Repeat

Begin

Set

Case

String

Const

Then

Div

Text

Do

To

DownTo

Type

Else

Uses

End

Until

File

Var

For

While

Function

With

If

Or

In

Procedure

Label

Program

Mod Nil Not Of 15

(

)

, : : Integer Real Boolean Char : True False MaxInt = 3,14159265358979

Pi

: Read ReadLn ReSet ReWrite Write WriteLn

– ,

:

. . ,

. ,

,

.

! . .

16

-

: 1)



ShortInt –

–128 … 127

1

Integer –

–32768 …+32767

2

LongInt –

–2 147 483 648 … 4 2 147 483 647

Byte –

0 … 255

1

Word –

0 … 65535

2

2)

– ± 2,9 × 10-39 …

Real –

11–12

6

7–8

4

±1,7 × 1038 Single –

-

± 1,5 × 10-45 … ±3,4 × 1038

Double –

-

± 5,0 × 10-324 … 15–16

8

±1,7 × 10308 Extended –

± 1,9 × 10-4951

19–20

10

19–20

8

… ±1,1 × 104932 Comp –

–2 × 1063 + 1… 2 × 1063 – 1

3)

– Boolean –

,

True – False –

17

-

4)

– Char –

,

-

: ‘a’

‘b’

5)

‘c’

‘0’

‘9’

‘#’

– String –

‘_’ ,

-

: 255

‘hello’ –

1.

(

.

) 5

-2

: 0

2.

: –

, . .

11–12 3.1415926535898 :

5.

.1

:

-2.13

5.0

0.5

– – (

-

): -2.3e-12

0.41E+5

-6.23e15 ( ),

. !

!

,

.

18

,

-

.

. . , , . , , .

-

,

,

-

: , ; , ; ; , ,

.

, ,

-

:

,

,

.

-

. . , ,

,

.

19

, ,

-



.

-

.

. ,

,

,

.

, .

,

, ,

-

,

,

,

. , ,

-

,

-

,–

.

-

. ,

,



,

. ,

-

: ,

,

,

,

.

.

-

, . , ( ,

, .

20

,

-

),

-

, 1)

:

,

2)

,

3)

,

4)

,

5) : 1)

,

2) . : ( ,

,

)

,

.

,

;

; ,

; ,

-

,

.

.



,

. : 21

-

Abs(x)

|x|

Abs(-2.5) = 2.5

Sqr(x)

x2

Sqr(25) = 625 x

Sqrt(x)

Sqrt(225) = 15

Exp(x)

ex

Exp(0.0) = 1.0

Ln(x)

ln x

Ln(1.0) = 0.0

Sin(x)

sin x

Sin(0.0) = 0.0

Cos(x)

cos x

Cos(0.0) = 1.0

Arctan(x) arctg x

Arctan(0.0) = 0.0

Trunc(x)

Trunc(2.7) = 2

Round(x)

Round(2.7) = 3

Frac(x)

Frac(2.7) = 0.7

Int(x)

Int(2.7) = 2.0

Pred(x)

Pred(5) = 4 Pred(-5) = -6 Pred(‘c’) = ‘b’

Succ(x)

Succ(5) = 6 Succ(-5) = -4 Succ(‘c’) = ‘d’

Ord(c)

Ord(‘A’) = 65 )

Ord(‘B’) = 66 Ord(‘0’) = 48 Ord(‘1’) = 49 Ord(1) = 1

Chr(x)

Chr(65) = ‘A’ )

Chr(48) = ‘0’

Odd(x)

Odd(7) = True Odd(8) = False

22

:

; Pred(), Succ() – ; Ord() –

;

Chr() – 32

255; Odd() –

.

,

-

. –

,

-

. ,

-

.

. , ,

,

-

. ,

,

,

.

23

-

-

,

-

: +

x + y

5 + 3 = 8

-

x – y

5 – 3 = 2

*

x * y

5 * 3 = 15

/

x / y

5 / 3 = 1

Div

x Div y

5 Div 3 = 1 10 Div 3 = 3 10 Div (-3) = -3 3 Div 5 = 0 125 Div 10 = 12

Mod

x Mod y

5 Mod 3 = 2 10 Mod 3 = 1 10 Mod (-3) = 1 3 Mod 5 = 3 125 Mod 10 = 5

, :

/

Div –

. ,

xa = ea

ln x

: Inc(x)

1

Inc(x, n)

n

Dec(x)

1

24

-

Dec(x, n)

n

: 1. 2.

:

3.

:

*

/

+

-

Div

Mod

. : (

)

;

*; ; Mod

.

Div

3y

3*y

(a + b)(c – d)

(a + b) * (c – d)

r – s * -5

r – s * (-5)

:

2a + 3b

2 * a + 3 * b

a b2

Sqrt(a) * b * b

5x3

5 * x * x * x

ab c + c ab

a * b / c + c / (a * b)

x-1

1 / x

log2 x

ln(x) / ln(2)

x100

Exp(100 * Ln(x))

31 x

Exp(Ln(1 + x) / 3) 25

, ,

:

+

x + y

5.2 + 3.1 = 8.3

-

x – y

5.2 – 3.1 = 2.1

*

x * y

5.2 * 3.1 = 16.12

/

x / y

5.0 / 2.0 = 2.5

(

),

,

,

2 ,

2.0,

-12,

-12.0 .

. : 2,5a + 0,973b2

2.5 * a + 0.973 * b * b

3,61·109 x – 526,237

3.61e9 * x – 526.237 * Sqrt(0.2*y)

0,2y

,

-

, ,

.

:

+,

-,

*,

/,

Div

,

+,

-, 26

Mod ,

*,

/

,

-

,

> < >= 1 = True ‘A’ > ‘F’ = False –

:

Ord(‘A’) = 65 Ord(‘F’) = 70

: )

Not And

)

Or

) , True,

,

,

False, ,



:

Not(5 < 2) = True (True)

And

(True)

Or

(False) = False (False) = True

27

(3 > 2)

Or

(‘A’ > ‘C’) = True

(3 > 2)

And

(‘A’ > ‘C’) = False

,

-

: True –

False –

. :

1)

Not

2)

*,

3)

/,

Div,

Mod,

And

+, -, Or

4)

>,

>=,

0)

Else, ,

Then z := z – 1

z = 4

Else z := z + 1;

2.

a

b,

: a>b

c=a

c=b

: (a > b) c = a c = b;

: If (a > b) Then

c: = a

Else

c: = b;

3.

:

57

,

)

: If (a > b)

a>b

Then c := a; If (b > a)

c=a

Then c := b;

b>a

c=b

)

:

c := b; c=b

If (a > b)

Then c := a;

a>b

c=a

, ,

.

-

: BEGIN … END. : sin c,

c < 2,5

c < 2,5

a = cos c,

c

2,5

a = sin c b=|c|

58

a = cos c b=1/c

| c |,

c < 2,5

b = 1/c,

c

2,5

: !

If (c < 2.5)

Else ,

Then

Then

!

Begin a:=Sin(c);

!

End

b:=Abs(c) End Else Begin a:=Cos(c); b:=1.0/c End;

If

Then

,

,

Else

If ,

.

If : 1.

x, y, z s:

)

:

x>y

x>z

s=x

y>z

s=z

s=y

59

s=z

-

(x > y)

If (x > y)

(x > z)

Then

s = x

If

(x > z)

Then

s = z

Else

(y > z)

Else

s = y s = z;

If

s:=x s:=z

(y > z)

Then

s:=y

Else

s:=z;

!

– .

)

:

1

s=z

x>y x>z

s=x

y>x y>z

s=y

s = z;

s := z;

(x > y) (x > z)

If (x > y) Then If (x > z)

s = x; (y > x) (y > z)

Then s:=x; If (y >x) Then If (y > z)

s = y;

Then

60

s:=y

2–

s=z

(x>y) & (x>z) (y>x) & (y>z)

s=x

s=y

s = z;

s := z;

(x > y) & (x > z)

If (x > y) And (x > z)

s = x;

Then

(y > x) & (y > z)

s:=x;

If (y >x) And (y > z)

s = y;

Then

s:=y;

, Else If: If (n>0) Then If (m Mod n > n) Then m := m – n Else m := m + n Else m := m Mod n;

Else m := m + n Else m := m Mod n

If (m Mod n > n), If (n > 0).

61

1.

:

If (n + m) Then . . . 2.

Else

Then:

If (n > m) Else . . . 3.

,

Then,

Begin

Else :

End

If (n > m) Then Begin a:=1; b:=0; Else . . . 4.

Else

Then:

If (n > m); Then a:=1; Else a:=0; 5.

:

If n > m

And

n m) Then a:=1 Else If (n 0

)

Write(‘n=‘);

ReadLn;

ReadLn(n);

End.

s := 0; (

)

i = n Mod 10 s=s+i n = n Div 10

3. –

0).

,

-

, . s–

,

min, max –

,

count – sred

, –

, 75

n–

. :

a)

s,

b)

n,

c)

, min

max

count = 1 s = s + n ; d)

n, , 1: count = count+1 s = s + n

e)

min,

min = n

max,

max = n

,

n # 0–

. – ,

: : 3 : : : :

8 1 -2 0

= 10 = 4 Min = -2 Max = 8 = 2.50

76

1

s=0 sred = s / count

n s, count, min, max, sred

(

n 0 (

)

)

min = n max = n count = 1 s=s+n

n

n 0

count = count + 1 s=s+n

n > max

max = n

n < min

min = n

1

77

If (n 0) Then

Program Posled;

Begin

Uses CRT; Var n, min, max, s, count:

count := count + 1;

Word;

s := s + n; If (n > max)

sred: Real;

Then max := n;

Begin

If (n < min)

ClrScr;

Then min := n;

s := 0; Write(‘

End;

:’);

{If (n 0)}

ReadLn(n);

End;

If (n = 0)

sred := s / count;

Then

{While}

WriteLn;

Exit;

min := n;

WriteLn(‘

=’,s);

max := n;

WriteLn(‘

count := 1;

=’,count);

s := s + n;

WriteLn(‘min=’,min);

While (n 0) Do

WriteLn(‘max=’,max); WriteLn(‘

Begin

-

=’,sred:5:2);

Write(‘O

ReadLn;

:’);

End.

ReadLn(n);

1.

:

While (n + m) Do . . . 2.

Do:

While (n < 10) . . . 3.

,

Do :

78

,

,

s:=0; n:=1; While (n < 10) Do; Begin s := s + n; n := n + 1; End;

(

)

,

:

(

);

) (

)

,

.

-

, ,

,

. . ,

.

79

,

, ,

,

. Repeat: Repeat

Until (

);

Repeat –

,

Until –

.

!

!

Repeat

.

Until ,

Begin … End.

Repeat: 1)

(

),

2)

, Until,

3)

,

,

4)

,

.

: 1.

: s = 1 + 2 + 3 + … + 98 + 99 + 100 s–

,

i –

(

1

100).

: a) b)

s, : i = 1,

c)

,

80

100.

: s=0 i=1

s = 0; i = 1;

s = s + i;

s=s+i i=i+1

i = i + 1; (i > 100);

i > 100

)

(

Program Gauss;

s := s + i;

Uses CRT;

i := i + 1;

)

Var i, s : Word;

Until (i>100);

Begin

WriteLn(‘s = ‘,

ClrScr;

s);

s := 0;

ReadLn;

i := 1;

End.

Repeat

2.

s

n.

s–

,

i –

. :

a)

s,

b)

,

-

10: i = n c)

Mod 10, : s = s + i,

d)

10

e)

: n = n Div 10, ,

n = 0–

. 81

Program Sum; Uses CRT; Var i, s, n : Word; n

Begin ClrScr; Write(‘n= ‘); s=0

ReadLn(n); s := 0; Repeat

i = n Mod 10 s=s+i n = n Div 10

i := n Mod 10; s := s + i; n := n Div 10;

(

)

Until (n = 0); n=0

WriteLn(‘s = ‘, s); (

)

ReadLn; End

3.

( –

0).

,

,

-

. s–

,

min, max –

,

count –

,

sred –

,

n –

. :

a)

s,

b)

n,

c)

, 1)

min 82

max

2)

count = 1

3)

s = s + n

4)

:

d)

n,

e)

, 1)

1: count = count +1

2)

s = s + n

3)

min,

min = n,

4)

max,

max = n,

f)

,

n = 0–

. g)

– ,

: : 3 : 8 : 1 : -2 : 0 = 10 = 4 Min = -2 Max = 8 = 2.50

83

1

s=0 sred = s / count

n s, count, min, max, sred

(

n 0 (

)

)

min = n max = n count = 1 s=s+n

n

n 0

count = count + 1 s=s+n

n > max

max = n

n < min

min = n

n=0

84

1

Program Posled;

Begin count := count + 1; s := s + n; If (n > max) Then max := n; If (n < min) Then min := n; End { If (n 0 )} Until (n = 0); sred := s / count; WriteLn; WriteLn(‘ =’,s); WriteLn(‘ =’,count); WriteLn(‘min=’,min); WriteLn(‘max=’,max); WriteLn(‘ =’,sred:5:2); ReadLn; End.

Uses CRT; Var n,min,max,s,count: Word; sred: Real; Begin ClrScr; s := 0; Write(‘ :’); ReadLn(n); If (n = 0) Then Exit; min := n; max := n; count := 1; s := s + n; Repeat Write(‘O :’); ReadLn(n); If (n 0) Then

4.

s– : 2 3 k s = 1 + x/ 1! + x / 2! + x / 3! + … + x / k! + … 0.

, yk+1

: = yk·x / k -

:

=|yn| :

0

>



0

,

, ,

,

85

-



10)



Then GoTo 5; For

i := 1

To

10

GoTo,

,

Do

92

-

Begin s := s + i; 5:

p := p + i; End;

6.

If

,

GoTo, , :

For

i := 1

To 100

Do

Begin If (a[i]=0) Then Goto 2; a[i] := 1 / a[i]; 2: End;

7. For

:

Break

i := 1

To 100

Do

Begin k := i; If (a[i] < 0) Then Break; End;

8.

Continue :

For

i := 1

To 100

Do

Begin If (a[i] = 0)

,

Then Continue; a[i] := 1 / a[i]; End;



, (

. 93

)

1.

.

, ,

: s := 0; For

i := 1

To 100

Do;

s = 100

s := s + i;

2.

-

To .

:

s := 0; For

i := 100

To 1

Do

s=0

s := s + i;

3. : s := 0.0; For

i := 1.0

To 100.0

Do

s := s + i;

4.

, :

m := 10; n := 1; For

j := m

DownTo

n

Do

Begin a[j] := j + 10; j := j + 1;

!

m := m + 1;

!

n := n – 1;

!

End;

94

( :

,

)

,

(

,

.

-

) . . , . -

,

,

-

, . , ,

,

-

, .

,

-

. : , , , , , . , (

).



-

,

,

,

.

95

,

.

,

25

-09

.

25

-

: is09_1, is09_2, is09_3, …, is09_25: Var

is09_1, is09_2, is09_3, …, is09_25: 2..5; . 25

:

ReadLn(is09_1); ReadLn(is09_2); ReadLn(is09_3); . . . . . . . . . . . . . ReadLn(is09_25); ,

,

:

sr_ball:=(is09_1+is09_2+is09_3+ . . . +is09_25)/25.0; , ?

? .

,

-

, . , , . ,

.

96

-

(

),

,

-

.

,

. ,

,

. ,

,

,

) .

,

,

-

.

,

-

: ,

.

,

,

-

. ,

,

-

: 1)

,

-

, 2)

,

3)

, , ,

4)

, ,

,

5)

,

6)



,

-

,

97

7)

, , . .

. Anm m

,

n

. -

aij –

j,

i

. :

(

),

,

. . -

. . –

,



-

. ( (

) )

. .

(

),

-

.

.

, .

,

, ,

. , ,

,

98



,

-

: a11

a12

a13



a21

a22

a23



a31

a32

a33



…………………….. ,

-

.

,

:

,

: a11, a12, a13,…, a21, a22, a23,…, ,

a31, a32, a33,… ),

(

(

). , ,



. , (

)

: ,

. . ( ,

,

)

)

, (

, ,

,

. ,

(

,

,

,

-

). -



, . 99

A23,

-

: -5

8

0

9

-1

4 :

) Var

:

A : Array [1..2,1..3] Of Integer;

,

1

2

1,2,3. !

,

-

,



!

. ,

,

-

{$R+}. . : Error 201: Range check error )

,

:

Const row = 2; Col = 3; Type TMatrix = Array [1..row,1..col] Of Integer; Var

A : TMatrix;

row

col (

-

), TMatrix

,

A

;

)

:

Const A : Array [1..2,1..3] Of Integer =((-5,8,0),(9,-1,4));

100

,

,

. . ,

,

-

. : 1.

Doska, . a h,



1

8,



-

.

:

Var Doska : Array [‘a’..’h’,1..8] Of Char;



:

Doska[‘c’,2]:=’f’;

, 2.

. -

Roma, (754 .

. .)

33 . . .

: Var Roma : Array [1..787] Of

Word;

: -

Roma[1]:=2;

33 .

Roma[787]:=450000;

.

450000

, . .?

,

-

, 639 .

101

,

. ,

: Var Roma : Array [-754..33] Of

,

Word;

639

. .

Roma[-639]. 3.

Ozenka, .

.

,

: .

.

.

.

4

5

5

.

3

4

3

: Var Ozenka : Array [1..2,1..3] Of

Word;

Ozenka[2,1]:=3;

,

.

3.

, Type

:

Fam = (Ivanov, Petrov); Predm = (Math, Phis, Inf);

Var Ozenka : Array [Fam, Predm] Of

2..5;

.

-

: Ozenka[Petrov,Math]:=3;

,

. ,

. .



.

. 102

, 5

A ,

3

,

4

:

Var a: Array [1..3, 1..4, 1..5] Of Integer; :

: 1.

-

vectorn ,

vect_min

vect_max. –

-

Random(k). , 0

k – 1.

Program Primer_1; Uses WinCrt; Const n = 10; vect_min = -10; vect_max = 20; Var

i : Word;

-

Vector : Array [1..n] Of Integer;

n

103

Begin ClrScr; Randomize; For i:=1 To n Do Vector[i]:=Random(vect_max – vect_min + 1) + vect_min;

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

ReadLn;

ENTER End.

2.

-

massivnm ,

mass_min

mass_max.

. Program Primer_2; Uses WinCrt; Const n = 5; m = 8; mass_min = -50; mass_max = 50; Var

i, j : Word; Massiv : Array [1..n, 1..m] Of Integer;

n Begin ClrScr; Randomize; For i:=1 To n Do

104

m

For j:=1 To m Do Massiv[i, j]:=Random(mass_max – mass_min + 1) + mass_min;

For i:=1 To n Do Begin For j:=1 To m Do Write(Massiv[i, j]:5); WriteLn; End; WriteLn;

ReadLn; End.

3.

1

massivnm n·m .

:

Program Primer_3; Uses WinCrt; Const n = 3; m = 5; Var

i, j, k : Word; Massiv : Array [1..n, 1..m] Of Word;

Begin ClrScr; k:= 0; For i:=1 To n Do For j:=1 To m Do Begin k:= k + 1; Massiv[i, j]:= k; End;

For i:=1 To n Do 105

Begin For j:=1 To m Do Write(Massiv[i, j]:5); WriteLn; End; WriteLn;

ReadLn; End.

4.

-

vectorn ,

vect_min

-

vect_max.

.

i_max .

vector_max

, : Program Primer_4; Uses WinCrt; Const n = 10; vect_min = -10; vect_max = 10; Var

i, i_max, vector_max : Integer;

Vector : Array [1..n] Of Integer; Begin ClrScr;

Randomize; For i:=1 To n Do Vector[i]:=Random(vect_max – vect_min + 1) + vect_min;

For i:=1 To n Do

106

Write(Vector[i]:5); WriteLn;



Vector_max:= Vector[1];

,

i_max:= 1;

!

For i:=2 To n Do If (Vector[i] >

Vector_max) Then

Begin

,

Vector_max := Vector[i]; i_max := i; End; WriteLn(‘Vector_max=’, Vector_max); WriteLn(‘i_max=’, i_max); ReadLn; End.

5.

-

vectorn ,

vect_min .

-

vect_max. .

S

, : Program Primer_5; Uses WinCrt; Const n = 10; vect_min = -50; vect_max = 50; Var

i, s : Integer; Vector : Array [1..n] Of Integer;

Begin ClrScr; Randomize; 107

For i:=1 To n Do Vector[i]:=Random(vect_max – vect_min + 1) + vect_min;

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

!

S := 0; For i:=1 To n Do s := s + Vector[i];

WriteLn(‘s=’, s);

ReadLn; End.

6.

-

vectorn ,

vect_min .

-

vect_max. :

,

(

):

Program Primer_6; Uses WinCrt; Const n = 10; vect_min = -50; vect_max = 50; Var

i, k, m : Integer; Vector : Array [1..n] Of Integer;

Begin ClrScr; Randomize;

For i:=1 To n Do Vector[i]:=Random(vect_max – vect_min + 1) + vect_min;

108

WriteLn(‘

:’);

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

m:= n Div 2; For i:=1 To m Do Begin k:= Vector[i]; Vector[i]:= Vector[n – i + 1]; Vector[n – i + 1]:= k; End;

WriteLn; WriteLn(‘

:’);

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

ReadLn; End.

7.

-

vectorn ,

vect_min . min

-

vect_max. ,

S max,

.

count

,

, :

Program Primer_7; Uses WinCrt; Const n = 10; vect_min = -50;

109

-

-

vect_max = 50; min = -10; max = 10; Var

i, s, count : Integer; Vector : Array [1..n] Of Integer;

Begin ClrScr; Randomize;

For i:=1 To n Do Vector[i]:=Random(vect_max – vect_min + 1) + vect_min;

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

count:= 0;

!

s:= 0; For i:=1 To n Do If (Vector[i] >= min) And (Vector[i] max) Then

,

Begin max:= Vector[i]; i_max:= i; End; End;

WriteLn; WriteLn(‘ WriteLn(‘

=’, Vector[i_min]); =’, i_min);

WriteLn(‘ WriteLn(‘

=’, Vector[i_max]); =’, i_max);

k:= Vector[i_min]; Vector[i_min]:= Vector[i_max]; Vector[i_max]:= k;

WriteLn; WriteLn(‘

:’);

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

ReadLn; End.

112

9.

-

vectorn ,

vect_min

-

vect_max.

.

.

,

– . i_otr

i_pol.

. ,



:

Program Primer_9; Uses WinCrt; Const n = 10; vect_min = -50; vect_max = 50; Var

i, k, i_otr, i_pol : Integer; Vector : Array [1..n] Of Integer;

Begin ClrScr; Randomize;

For i:=1 To n Do Vector[i]:=Random(vect_max – vect_min + 1) + vect_min;

WriteLn(‘

-

:’);

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

i_otr:= 0; i_pol:= 0;

For i:=1 To n Do

113

If (Vector[i] < 0) Then

,

Begin i_otr:= i; Break; End;

For i:=1 To n Do If (Vector[i] > 0)

,

Then i_pol:= i;

If (i_otr = 0) Then WriteLn(‘

’);

If (i_pol = 0) Then WriteLn(‘

’);

If (i_otr > 0) And (i_pol > 0) Then Begin

WriteLn; WriteLn(‘ WriteLn(‘

=’, Vector[i_otr]); =’, i_otr);

WriteLn(‘

=’,

Vector[i_pol]); WriteLn(‘

=’, i_pol);

k:= Vector[i_otr]; Vector[i_otr]:= Vector[i_pol]; Vector[i_pol]:= k;

WriteLn; WriteLn(‘

:’);

For i:=1 To n Do

114

Write(Vector[i]:5); WriteLn; End; ReadLn; End.

10.

-

vectorn ,

vect_min

-

vect_max.

. ,

.

,

posl, ,

posl :

Program Primer_10; Uses WinCrt; Const n = 10; vect_min = -50; vect_max = 50; Var

i, k, posl : Integer; Vector : Array [1..n] Of Integer;

Begin ClrScr; Randomize; For i:=1 To n Do Vector[i]:=Random(vect_max – vect_min + 1) + vect_min; WriteLn(‘

:’);

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

115

-

posl:= Vector[n];

For i:= n DownTo 2 Do Begin k:= Vector[i]; Vector[i]:= Vector[i-1]; Vector[i-1]:= k; End;

Vector[1]:= posl;

WriteLn; WriteLn(‘

:’);

For i:=1 To n Do Write(Vector[i]:5); WriteLn;

ReadLn; End.

11.

vectork ,

vect_min .

Program Primer_11; Uses WinCrt; Const k = 12; vect_min = -50; vect_max = 50; n = 3; m = 4; Var

mas-

(n*m = k):

sivnm

vect_max.

-

i, j, t : Integer;

116

Vector : Array [1..k] Of Integer; Massiv : Array [1..n, 1..m] Of Integer; Begin ClrScr; Randomize;

For i:=1 To k Do Vector[i]:=Random(vect_max – vect_min + 1) + vect_min;

WriteLn(‘

’);

WriteLn; For i:=1 To k Do Write(Vector[i]:5); WriteLn;

t := 0; For i:=1 To n Do For j:=1 To m Do Begin t := t + 1; Massiv[i, j] := Vector[t]; End;

WriteLn(‘

’);

WriteLn; For i:=1 To n Do Begin For j:=1 To m Do Write(Massiv[i, j]:5); WriteLn; End;

ReadLn; End. 117

12.

massivnm ,

mass_min

mass_max.

. Vectork

(k = n*m):

Program Primer_12; Uses WinCrt; Const n = 5; m = 7; k = n * m; mass_min = -50; mass_max = 50; Var

i, j, t : Integer; Vector : Array [1..k] Of Integer;

Massiv : Array [1..n, 1..m] Of Integer; Begin ClrScr; Randomize;

For i:=1 To n Do For j:=1 To n Do Massiv[i, j]:= Random(mass_max – mass_min + 1) + mass_min;

WriteLn; WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To m Do Write(Massiv[i, j]:5); WriteLn; End; WriteLn;

118

-

-

t := 0; For i:=1 To n Do For j:=1 To m Do Begin t := t + 1; Vector[t] := Massiv[i,j]; End;

WriteLn(‘

’);

WriteLn; For i:=1 To k Do Write(Vector[i]:5); WriteLn;

ReadLn; End.

13.

-

massivnn ,

mass_min

mass_max.

.

, :

,





.

-

. Program Primer_13; Uses WinCrt; Const n = 5; mass_min = -50; mass_max = 50; Var

i, j, k : Integer; Massiv : Array [1..n, 1..n] Of Integer;

n

119

Begin ClrScr; Randomize;

For i:=1 To n Do For j:=1 To n Do Massiv[i, j]:=Random(mass_max – mass_min + 1) + mass_min;

WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To n Do Write(Massiv[i, j]:5); WriteLn; End; WriteLn;

For i:=1 To n Do For j:=i To n Do Begin k:= Massiv[i,j]; Massiv[i,j]:= Massiv[j,i]; Massiv[j,i]:= k; End;

WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To n Do Write(Massiv[i, j]:5); WriteLn; End;

120

WriteLn;

ReadLn; End.

14.

-

massivnm ,

mass_min

mass_max.

. ,

.

. : Program Primer_14; Uses WinCrt; Const n = 5; m = 6; mass_min = -50; mass_max = 50; Var

i, j, k, posl : Integer; Massiv : Array [1..n, 1..m] Of Integer;

Begin ClrScr; Randomize;

For i:=1 To n Do For j:=1 To m Do Massiv[i, j]:= Random(mass_max – mass_min + 1) + mass_min;

WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To m Do Write(Massiv[i, j]:5); 121

WriteLn; End; WriteLn;

For i:=1 To n Do Begin

posl:= Massiv[i, m]; For j:=m DownTo 2 Do Begin k:= Massiv[i,j]; Massiv[i,j]:= Massiv[i, j-1]; Massiv[i, j-1]:= k; End;

Massiv[i,1]:= posl;

End;

WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To m Do Write(Massiv[i, j]:5); WriteLn; End; WriteLn;

ReadLn; End.

122

15.

-

massivnn ,

mass_min

mass_max.

. ,

90º

: 1

2

3

4

5

6

7

8

9

=>

7

4

1

8

5

2

9

6

3 ,

– Program Primer_15; Uses WinCrt; Const n = 5; mass_min = -50; mass_max = 50; Var

i, j, k, m : Integer; Massiv : Array [1..n, 1..n] Of Integer;

Begin ClrScr; Randomize;

For i:=1 To n Do For j:=1 To n Do Massiv[i, j]:= Random(mass_max – mass_min + 1) + mass_min; WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To n Do Write(Massiv[i, j]:5); WriteLn; End; WriteLn; 123

:

For i:=1 To n Do For j:=i To n Do Begin k:= Massiv[i,j]; Massiv[i,j]:= Massiv[j,i]; Massiv[j,i]:= k; End;

WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To n Do Write(Massiv[i, j]:5); WriteLn; End; WriteLn;

m:= n Div 2; For i:=1 To n Do For j:=1 To m Do Begin k:= Massiv[i,j]; Massiv[i,j]:= Massiv[i, n – j + 1]; Massiv[i, n – j + 1] := k; End;

WriteLn; WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To n Do Write(Massiv[i, j]:5); WriteLn; 124

End; WriteLn;

ReadLn; End.

16.

massivnm ,

mass_min

mass_max.

.

. , :

Program Primer_16; Uses WinCrt; Const n = 5; m = 10; mass_min = -50; mass_max = 50; Var

i, j, k, i_max, j_min : Word; min, max : Integer; Massiv : Array [1..n, 1..m] Of Integer;

Begin ClrScr; Randomize;

For i:=1 To n Do For j:=1 To m Do Massiv[i, j]:= Random(mass_max – mass_min + 1) + mass_min;

WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To m Do Write(Massiv[i, j]:5);

125

-

WriteLn; End; WriteLn;

For i:=1 To n Do Begin min:= Massiv[i,1]; j_min:= 1;

For j:=2 To m Do If (Massiv[i,j] < min) Then Begin min:= Massiv[i,j]; j_min:= j; End;

,

max:= Massiv[1, j_min]; i_max:= 1;

For k:=2 To n Do If (Massiv[k,j_min] > max) Then Begin max:= Massiv[k,j_min]; i_max:= k; End;

If (i = i_max) Then Begin WriteLn(‘

=’,i,



=’,j_min,



=’, Massiv[i, j_min]);

Break; End; 126

End;

ReadLn; End.

17. ,

mass_min .

ann

-

mass_max.

-

vk

,

-

(k = 2n – 1). : a11

a12

a13

a14

. . . a1n

a21

a22

a23

a24

. . . a2n

a31

a32

a33

a34

. . . a3n

. . . . . . . . . . . . . an1

an2

an3

an4

,

. . . ann

:

v1 = a11

1+1=2

v2 = a21 + a12

1+2=3

v2 = a31 + a22 + a13

1+3=4

. . . . . . . . . n + n = 2n

v2n-1 = ann ,

,

,

-

: Program Primer_17; Uses WinCrt; Const n = 5; k = 2*n - 1; mass_min = -50; 127

mass_max = 50; Var

i, j, t : Integer; vector : Array [1..k] Of Integer;

a : Array [1..n, 1..n] Of Integer; Begin ClrScr; Randomize;

For i:=1 To n Do For j:=1 To n Do a[i, j]:= Random(mass_max – mass_min + 1) + mass_min;

WriteLn; WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To n Do Write(a[i, j]:5); WriteLn; End; WriteLn;

For i:=1 To k Do vector [i]:= 0;

For i:=1 To n Do For j:=1 To n Do Begin t:= i + j - 1; vector[t]:= vector[t] + a[i,j];

End;

128

-

WriteLn; WriteLn(‘

’);

WriteLn; For i:=1 To k Do Write(vector[i]:5); WriteLn;

ReadLn; End.

18. ,

mass_min

ann

-

mass_max.

-

.

vk

,

-

(k = 2n – 1). : a11

a12

a13

a14

. . . a1n

a21

a22

a23

a24

. . . a2n

a31

a32

a33

a34

. . . a3n

. . . . . . . . . . . . . an1

an2

an3

an4

. . . ann

: vn

vn-1 vn-2 vn-3 . . . v2

vn+1 vn

vn-1 vn-2 . . . v3

vn+2 vn-1 vn

vn-2 . . . v4

v1 v2 v3

. . . . . . . . . . . . . . . . V2n-1 v2n-2 v2n-3 v2n-4 . . . vn+1 : Program Primer_18; Uses WinCrt; Const n = 5; 129

vn

k = 2*n - 1; mass_min = -50; mass_max = 50; Var

i, j, m, t : Integer; vector : Array [1..k] Of Integer;

a : Array [1..n, 1..n] Of Integer; Begin ClrScr; Randomize;

For i:=1 To n Do For j:=1 To n Do a[i, j]:= Random(mass_max – mass_min + 1) + mass_min;

WriteLn; WriteLn(‘

:’);

For i:=1 To n Do Begin For j:=1 To n Do Write(a[i, j]:5); WriteLn; End; WriteLn;

For i:=1 To k Do vector[i]:= 0;

m:= n-1; For i:= 1 To n Do Begin m:= m+1; t:= m; For j:=1 To n Do 130

Begin vector[t]:= vector[t] + a[i,j]; t:= t - 1; End; End;

WriteLn; WriteLn(‘

’);

WriteLn; For i:=1 To k Do Write(vector[i]:5); WriteLn;

ReadLn; End.

19.

massivknm 1

k*n*m . :

Program Primer_19; Uses WinCrt; Const k = 3;

131

,

-

n = 4; m = 5; Var

i, j, b, c : Word; Massiv : Array [1..k, 1..n, 1..m] Of Word;

:

Begin

ClrScr; c:= 0;

For i:=1 To k Do For j:=1 To n Do For b:=1 To m Do Begin c:= c + 1; Massiv[i, j, b]:= c; End; WriteLn('

:');

For i:=1 To n Do Begin For j:=1 To m Do Write(Massiv[1, i, j]:5); WriteLn; End; WriteLn; WriteLn('

:');

For i:=1 To k Do Begin For j:=1 To m Do Write(Massiv[i, n, j]:5); WriteLn; End; 132

,

,

WriteLn; WriteLn('

:');

For i:=1 To k Do Begin For j:=1 To n Do Write(Massiv[i, j, m]:5); WriteLn; End; WriteLn;

ReadLn; End.

: : 1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

: 16

17

18

19

20

36

37

38

39

40

56

57

58

59

60

: 5

10

15

20

25

30

35

40

45

50

55

60

133



,

,

.



ASCII

255

-

Char. (

)

(

)

-

,

. –

,

-

:

,

,

-

,

. , ,

,

,

:

-

, ,

,

.

,

,

. :

Var Var

255

str_1: String; str_2: String[25];

25

str_3: String[10];

10 :

Const Const my_str=’

’;

klav=’qwerty’;

134

ASCII,

-

: Const

klav=#113#119#101#114#116#121;

: Const

ASCII

klav=^1^7^%^2^4^9;

^. ASCII,

:

Program Table_ASCII; Uses CRT; Const n: String[16] = '0123456789ABCDEF'; s: String = '--+-----------------------------------------'; Var i, j: Byte; c: Char; f: Text; Begin ClrScr; Assign(f, 'D:\User\ASCII.txt'); ReWrite(f); Write(f, '

| ');

For j:=0 To 15 Do Write(f, n[j+1],'

');

WriteLn(f); WriteLn(f, s); Write(f, '0 | '); For j:=0 To 15 Do Begin If (j In [9,10,13]) Then c:=' ' Else c:=Chr(j); Write(f, c, '

');

End; WriteLn(f); 135

For i:=1 To 15 Do Begin Write(f, n[i+1],' | '); For j:=0 To 15 Do Write(f, Chr(i*16+j), ' WriteLn(f); End; WriteLn(f, s); WriteLn(f); Close(f); End.

– , –

:

136

');

,

– 30,

48

-

. –

,

,

-

,

-

.

F–

,

,

. ,

.

. ,

S–

^S –

-

,

,

,

, ^}

=,

.

^=

}. ,

-

. ^

-

CTRL,

-

.

, :

¬

-

). . 1

(

.

).

ASCII-

, Ord(my_str[0])=19 –

. 19

,

,

. :

srt_1 := ‘

’;

srt_2 := ‘

’;

,

:

ReadLn(str_1);

137

, ,

,



. ,

:

WriteLn(str_1);

,

,

: 1.

(

)

:

str_1 :=’Turbo’; str_2 := ‘ Pascal’;

str_3

str_3 := str_1 + str_2;

2.

Turbo Pascal



>, >=, ‘Vasja’ = True

: 1. Length(

)–

(



):

str_1 :=’Turbo’;

n=5–

n := Length(str_1);

2. Pos(

_2) –

_1, _2 (

str_1 :=’

5 _1





):

’;

str_2 :=’ n := Pos(str_1, str_2);

’;

n=3 –

str_1

str_2,

!

3

,

138

-

.

3. Copy(

,

)–

,

-

, ;

:

str_1 :=’

’;

,

str_2:=Copy(str_1, 2, 3);

-

,

3

; 4. Concat( (

_1, )

str_2=’



_3, ...) –

_2,

;

-

:

str_1 :=’Turbo’; str_2 := ‘ Pascal’;

str_3

str_3 := Concat(str_1, str_2);

Turbo Pascal

!

255

. :

1. Delete(

,

,

-

) – ,

; str_1 :=’

_1: ’;

,

Delete(str_1, 4, 2);

-

,

2

; 2. Insert(

_1,

_1

str_1=’

_2,



) – ;

_2, _2:

str_1 :=’ str_2 :=’

’; ’;

,

Insert(str_1, str_2, 3);

,

; str_2=’

139



-

,

,

-

,

. :

1. Str(

) –

,

-

: x:= 3.14;

str_1

Str(x, str_1);

‘3.14’ 2. Val(

,

)–

,

.

-

, .

-

(

), ,

: str_1 := ‘3.14’;

str_1

Val(str_1, x, n);

n = 0(

x=3.14, )

str_1 := ‘3,14’; Val(str_1, x, n);

,

str_1 n = 2(





), x

-

Invalid numeric format, ,

-

.

, ,

Val, ,

. 140

-

1

. –

, 2400

.

,

-

,

, ,

-

. .

, , . ,





. , .

XIX ,

(

-

,

). ,

, . , . ,

,

, – «2>5» –

: ,

»–

, »–

. : A, B, C… .

.

. -

. , 1) 2)

: ; .

141

,



. ,

-

, . : ( ; ; (

);

); . (

) ».

A ,

.

,

,

,

. , :

A 1 0

0 1 :



»,

A =« A =«

»,

,

». (



) . & (A&B)

, ,

-

, ,

: A 0 0 1 1

B 0 1 0 1

142

A&B 0 0 0 1

^.

:

=« =«

2», 3», A&B = « 3» –

2

-

6. (



)

. +

.

(A+B) ,

, ,

, A 0 0 1 1 :

-

B 0 1 0 1

: A+B 0 1 1 1

=« =«

», », A+B = «

»–

. (

…,

)

…»

-

. :

=>. »,

=« =« A=>B =

», , ». . :

,

.

-

. , ,

, ,

: 143

» (A=>B)

-

A 0 0 1 1

B 0 1 0 1

A=>B 1 1 0 1 ,

,

:

A

A=>B

)

«…

,

…»

. ~. :

=« – =« A B =« –

», »,

,

». A

B

,

:

A 0 0 1 1

B 0 1 0 1

A

B 1 0 0 1 ,

A

:

A & B + A&

B ,

,

,

,

,–

-

, . , –

, –

, –

, . : ; ; ; ; 144

, (1)

(0). -

; ; ; ;

: + A

1 . :

0 1

+A 1 1

A 1 0

: Tertium non datur, « :

». =«

»,

A =«

», +A = « ».

»

, +A ,–

, ,

.

, .



– .

. ,

,

,

.

: & A

0 . :

0 1

A 1 0 145

&A 0 0

:



»,

A =«

», &A = « ».

&A



, ,

,

,

.

.

:

A . : 0 1 :

A 1 0

A 0 1



»,

A =«

»,

A =« «

,

».

,

» ».

-

: (A=>B)

( B => A ) , . -

:

». =« =«

», »,

146

A=>B = «

,

».

B => A = « ».

,

-

« ,

-

».

: (A& C => B )

(A&B=>C)

, . :

=« 31 =« =« (A& )=> = « ,

», », », 31»,

(A& C => B ) = « ,

A=>(B=>C)

31».

-

: B=>(A=>C) -

, , , . :

31-

=« =« 31 =« A=>(B=>C) = « , B=>(A=>C) = « ,

147

», », », , », 31».

,

-

: (A=>B )& (B=>C)

(A=>C) ,

-

, . :

,

=« =« », =« », (A=>B)& (B=>C) = « , », (A=>C) = « , ».

»,

, -

:

A B A& B

A& B A + B ,

-

,



, – 1:



.

,

= A.

A B = A A = 1 = 0, )



A & B = A & A = A &A = 0. 2: =« =« A+B=« 5».

0», 5». 0 5.

148

-

-

5

A B = A& B = « 5».

0

,

-

, (

),

-

. : –

( A+B A&B



) : B+A B&A

: A + (B + C) (A + B) + C A & (B & C) (A & B) & C : A & (B + C) A & B + A & C A + B & C (A + B) & (A + C)





: A + A&B = A&(1 + B) = A A&(A + B) = A&A + A&B = A + A&B = A&(1 + B) = A :



A&B + A& B = A&(B + B ) = A&1 = A : A+A=A A&A=A



: A+0=A A+1=1 A&0=0 A&1=A

A A& B

A B -

,

: F = A& B + A&B A B F 0 0 0 0 1 0 1 0 1 1 1 1

149

: A 0 0 1 1

B 0 1 0 1

F 1 0 1 0 ,

: A 0 1

B 0 0

F 1 1 ,

,

: F = A & B +A& B :

F = A & B +A& B = B &( A + A) = B & 1 = B

, ,

,



.

,

A& B A B ,

-

:

A& B A B

A B A& B

A B & (1 A)

A B .

1. , :

A A 1 A& A 0

A A A B

A& B

A& B

A B 150

-

A + A&B = A A&B + A& B = A A+A + A A&A = A

, :

A

B

A B

A

B

A& B A& B :

A & C A & B A & C B & C & D & ( A A & B & C) A & C A & B & A & C B & C & D & ( A B & C)

A & C ( A B) & ( A C ) B & C & D & ( A B & C ) A & C ( A & A A & C A & B B & C) B & C & D & ( A B & C) A& C A&C A& B B &C A& B &C & D

C & ( A A B) A & B A & B & C & D C &1 A & B & (1 C & D) C A& B ,

.

2. , -

, – . : X 0 0 1 1

Y 0 1 0 1

F 1 0 1 0 ,

: 151

F = X &Y

X &Y

,

,

: X

X Y

Y

, : X

1

X

1

Y

Y ,

,

(

,

).

, ,

.

Y.

: F = X &Y :

X &Y = Y

1

X

1

X Y

Y

: F=X : 1

X

1 1

X Y

Y ,

-

: 152

F

X

Y :

X

1

1

X

1

1

Y

Y : F=1 ,

, . :

Z

Z

Z

X

X Y

Y

, .

,

:

Z X

Z

1

Z

1 1

X

1

Y

Y , : F = X&Y + Y&Z + X &Z

153

-

:

Z X

X

Z

Z

1

1

1

1

Y

Y : F=Y ,

-

:

Z

Z

Z

1

X

1

X Y

Y : F = X& Z :

Z X

X

Z

Z

1

1

1

1

Y

Y

F= Z

154

2

– : 6, 1102, XI. ,

,

,



.

,

,

-

. – : • •• ••• :

(

)

. ,

-

: I V X L C D M

1 5 10 50 100 500 1000 –

:

VI IV

6 4 , ,



– I V. 1 5, . :

, -

: MCMXCIII – 1993, . : 354 = 3×100 + 5×10 + 4×1

155

3, 5 1– , ,

, 100, 10

4

. . ,

,

,

-

S = 10: 354 = 3×10 + 5×101 + 4×100 2

,

:

0

10 101 102



! , . ,

.

, –

. ,

: 1, 10, 100, 1000, 10000, … -

. . : : –

0, 1



: 1, 2, 3, 5, 8, 13, 21, … :



:

1!, 2!, 3!, …

:0

1.

, – 0, 1 S=2 0

1

2

3

4

–2 ,2,2 ,2 ,2 ,… 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,… : 0

1

2

3

10112 = 1×2 + 1×2 + 0×2 + 1×2 = 1 + 2 + 0 + 8 = 1110 .

156



– 2

: 11/2 = 5, 5/2 = 2, 2/2 = 1, 1/2 = 0,

1 1 0 1,

10112.

: 0, 1, 2, 3, 4, 5, 6, 7 S=8 – 8: 80, 81, 82, 83, …

1, 8, 64, 512, … -

: 35728 = 2×80 + 7×81 + 5×82 + 3×83 = 2×1 + 7×8 + 5×64 + 3×512 = 191410 . –

-

– 8 : 1914/8 = 239 239/8 = 29 29/8 = 3 3/8 = 0

2 7 5 3,

35728. – :

1.

(

-

): 100110001012 = 010 011 000 1012 2. : 010 011 000 1012 = 23058 2 3 0 5 : 23058 = 010 011 000 1012 2 3 0 5

157

: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F 10, 11, 12, 13, 14, 15). S = 16 – 16: 160, 161, 162, 163, …

1, 16, 256, 4096, …

: A5D16 = D×160 + 5×161 + A×162 = 13×1 + 5×16 + 10×256 = 265310 . – – 16 : 2653/16 = 165 165/16 = 10 10/16 = 0

13, 5 10,

D A,

A5D16.

– : 1.

(

-

): 100110001012 = 0100 1100 01012 2. : 0100 1100 01012 = 4C516 4 12 = C 5 : A5D16 = 1010 0101 11012 A 5 D : 10-

0

1

2

3

4

2-

0

1

10

11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 1111

16-

0

1

2

3

4

5

5

6

6

7

7

158

8

8

9

9

10

A

11

B

12

C

13

D

14

E

15

F

: 0+0=0 0+1=1 1+0=1 1 + 1 = 10

) :

1111 11 11 10110110012 + 1110110112 ------------100101101002 , : 10111110012 1110110112 ------------1000111102 : 1000111102 + 1110110112 ------------10111110012

, 1 5638

,

-

+ 528 ----6358

159

9, 7:

: 68 + 58 --138 8– .

2,

.

3,

,

-

. : 5238 528 ----4518

, F (15): 1 9DA16 + 8216 ----A5C16

9,

,

-

: D16 + 816 --1516 16 –

(D = 13) 3, 5,

. . ,

. -

: A5C16 8216 ----9DA16

160

3

1.

1 2

Out of memory Identifier expected

3 4

Unknown identifier Duplicate identifier

5

Syntax error

6

Error in real constant Error in integer constant String constant exceeds line Too many nested files Unexpected end of file Line too long Type identifier expected Too many open files Invalid file name

7 8 9 10 11 12 13 14 15 16 17 18

. . . .

-

-

.

File not found Disk full Invalid compiler directive Too many files

. -

20

Variable identifier expected

161

21

Error in type

22

Structure too large

. .

– 64

23

.

Set base type out of range

0…255 256

24

25 26 27

28

29

30 31 32 33 34

File components may not be files or objects Invalid string length Type mismatch Invalid subrange base type Lower bound greater than upper bound Ordinal type expected

. – 255 .

-

. ,

39 40

-

,

-

Integer constant expected Constant expected Integer or real constant expected Pointer type identifier expected Invalid function result type

-

. ,

36 37 38

-

Begin End

Begin expected End expected Integer expression expected Ordinal expression expected Boolean expression expected

162

-

41 42 43 45 48 49 50 54 55 57 58 62 63 64

65 66 67 68

69

Operand types do not match operator Error in expression Illegal assignment Object file too large Code segment too large 64 Data segment too large DO expected OF expected INTERFACE expected THEN expected TO or DOWNTO expected Division by zero Invalid file type Cannot Read or Write variables of this type Pointer variable expected String variable expected String expression expected Circular unit reference Unit name mismatch

– 64 – – 64 Do Of

Then To

DownTo

-

.

-

.

, .tpu,

,

-

Uses 73 74

– Implementation ( ) ) Case

Implementation expected Constant and case types do not match

163

-

75 76 77 78 79 81 82

84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

102 103

«

Record variable expected Constant out of range File variable expected Pointer expression expected Integer or real expression expected Label already defined Undefined label in processing statement part Unit expected ‘;’ expected ‘:’ expected ‘,’ expected ‘(’ expected ‘)’ expected ‘=’ expected ‘:=’ expected ‘[’or ‘(‘ expected ‘]’or ‘)‘ expected ‘.’ expected ‘..’ expected Too many variables Invalid FOR control variable Integer variable expected Files are not allowed here String length mismatch

»

«

» -

Unit ‘;’ ‘:’ ‘,’ ‘(’ ‘)’ ‘=’ ‘:=’ ‘[’ ‘]’ ‘.’ ‘..’

‘(‘ ‘)‘

For –

-

.

String constant expected Integer or real variable expected

-

164

104 106 108

109

112 123

Ordinal variable expected Character expression expected Overflow in arithmetic operation No enclosing FOR, WHILE or REPEAT statement CASE constant out of range Too many symbols

-

– LongInt Break Continue

Case –32768…32767



-

64 124 132 137

140

145

Statement part too large Cannot evaluate this expression Structured variable are not allowed here Invalid floatingpoint operation

146

Too many nested scopes File access denied

147

Object type expected





.

)

18

-

24

2.

2 3 4 5 15

-

MS-DOS

File not found Path not found Too many open files File access denied Invalid driver number No more files

165

-

) {$I-}

-

IOResult

100 101 102

Disk read error Disk write error File not assigned

103 104

File not open File not open for input File not open for output Invalid numeric format

105 106

.



)

150 151 152 153 160 161 162

Disk is write protected Unknown unit Disk not ready Unknown command Device write fault Device read fault Hardware failure )

200 201 202 204 205

Division by zero Range check error Stack overflow error Invalid pointer operation Floating point overflow 166

206 207 210 215

Floating point underflow Invalid floating point operation Object not initialized Arithmetic overflow

-

167

. – . .

.-

. . 11,55.

168

27.10.2014 2014 .

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 AZPDF.TIPS - All rights reserved.