.


:




:

































 

 

 

 


 

, , : .

, .

:

Const

=;

1. , , .

2. , .

3. , .

4. , .

5. False, True.

6. . , .

:

Const

:=;

7. :

Pi Real 3.1415926536
True Boolean True
False Boolean False
Maxint Integer  

:

Const

A=2; {}

B=2.35; {}

St=g; {}

R=!; {}

Year:Integer=2005; {}

. . . , - .

:

Var

:;

 

 

, , , .

-

 

. .

,
Byte   0..255
ShortInt   -128..127
Word   0..65535
Integer   -32768..32767
LongInt   -2147483648.. 2147483647

(Boolean). False True.

 

(Char). . ASCII (American Standart Code for Information Interchange ).

 

. , . , .

:

Type

_=_;

Var

: _;

:

Type

Colors=(black, red, white);

Var Col:colors;

:

Var

Col:(black, white, green);

 

-. - , , -. - :

_.. _

:

Type

Digit=0..9;

Dig2=48..57;

Var

D1:Digit;

D2:Dig2;

- . :

Var

Date:1..31;

Month:1..12;

 

. , .

, -
Real   11..12 -39..38
Single   7..8 -45..38
Double   15..16 -324..308
Extended   19..20 -4932..4932
Comp   10..20 -2*1063+1.. 2*1063-1

:

Var

Min:Real;

 

4 :

1) , not ; @ ;

2) * (), mod ( ), div ( ), / (), and ( ""), shl , shr ;

3) : + (), (), or ( ""), xor ( "");

4) : = (), <> ( ), > (), < (), >= ( ), <= ( ), in ( ).

:

F:=2*sin(x)+3/sqrt(1+x*x);

 

(div) , . , .

 

(mod) , .

:

11 div 5 = 2; 2 div 3=0;

11 mod 5=1; 14 mod 5=4

 

A B
not Not A True False   False True
and A and B True True False False True False True False True False False False
or A or B True True False False True False True False True True True False
xor A xor B True True False False True False True False False True True False

(shl, shr):

i shl j i j ; ( 1 i 2);

i shr j i j ; ( 1 i 2).

, . .

:

abs(x) | x |,

arctan(x) arctg x,

cos(x) cos x,

exp(x) ex,

int(x) x,

frac(x) x,

ln(x) ln x,

sin(x) sin x,

sqr(x) x 2,

sqrt(x) ,

Random , 0..1;

Random(x) , 0.. x- 1;

Randomize .

, :

Pred (S) , S;

Succ (S) , S;

Odd (I) , True, I , False, I .

:

Round(x) x, , ;

Trunc(x) x, x 0, x, x <0. ;

Chr(i) , i.

Ord(s) s , s.

 

:

Round(3.7); 4

Round(-46.317) 46

Trunc(3.7); 3

 

, :

Dec(i) I ( i:=i-1);

Inc(i) I ( i:=i+1);

Hi(i) ( byte word);

Lo(i) ( byte word);

Swap(i) .

 

, :

Chr(I) , I;

UpCase(ch) .

, -:

High(x) -, x;

Low(x) -.

 

-

 

- 4 : Read, ReadLn, Write, WriteLn.

Read , , .. . :

Read (X1,X2,,Xn);

X1, X2, , Xn .

X1,,Xn . Read Enter. .

Read, , .. Read Read , , .

.

Var A,B: Integer; C,D: Real; Begin Read (A,C); Read (B,D); End. : 25 2.34<Enter> 451 25.685<Enter>

 

ReadLn Read, , ReadLn ReadLn . Read ReadLn:

 

Var A,B: Integer; C,D: Real; Begin ReadLn (A,C); ReadLn (B,D); End. : 25 2.34 <Enter> 451 25.685 <Enter>  

Write , , . :

Write (Y1,,Yn);

Y1,,Yn , , , , . .

:

Write (I); 134 134

Write (I:5); 134 _ _134

( 5 . ).

Write (R); 715.342 _ _7.153420000E+02

Write (R:12); 46.78 4.678000E+01

( 12 ).

Write (R:6:2); 46.78 _46.78

( 6 , 2 . ).

Write (CH); 'X' X

Write (CH:4); 'X' _ _ _X

Write (S); '!' !

Write (S:10); '!' _ _ _!

Write (B); True True

Write (B:6); True _ _True

WriteLn Write, WriteLn . WriteLn, , .

:

Write ('A=',A:3);

WriteLn ('_C=',C:3);

WriteLn ('D=',D:6:2);

A=_23_C=_34

D=_ _3.24

 

 

, . .

2 : .

, , . , , . , . 3 :

,

,

.

, :

;

;

;

- ;

- .

 

1. , , , .

:

:=;

:

;

;

;

, .

. . :

1. .

2. () , , :

Var

k:Integer;

Begin

Byte(k); { k }

End.

:

, , , ;

, ( ).

2. Goto. , . . Goto , , - , .

:

Goto ;

:

Label

_;

Goto :

1. , , , , , .

2. , .

3. .

:

Goto met1;

met1: ;

Goto . .

3. . , , . (;).

:

Goto m7;

...

m7:;

4. , begin end. , .

:

 

begin

1;

N;

nd;

 

5. , . : If Case.

If. :

If then _1

else _2; { }

If then ; { }

If, If. . . . .

, _1, _2. , , , If.

If If. :

If then

If then 1

else 2;

else then, .

:

If ((A>B) and (C<D)) then

If (Z>=X) then Writeln ('')

else Writeln (' ')

else WriteLn ('');

 

Case If . , , , ( ). If, Else, . :

ase - of

_1: _1;

_2: _2;

...

_N: _N

else

end;

Case , -. , Case , nd, , Else.

- . , .

:

Case X of {- }

1,2,3: A:=B+C;

4: A:=B-C;

5..9: A:=B*C

else A:=B/C

end;

 

Case CH of {- }

'A'.. 'z': WriteLn (' ');

'0'.. '9': WriteLn (' ')

end;

6. . , . , For, , Repeat While.

For . :

For _:=_ to _ do

;

For _:=_ downto _ do

;

. For , .

, . , . Forto , Fordownto .

. 0 100.

Program DemoFor;

Var

I, Sum: Integer;

Begin

Sum:=0;

For i:=0 to 100 do

Sum:=Sum+I;

WriteLn (' ',Sum);

End.

 

repeat (Repeat), (Until).

:

Repeat

_1;

...

_n;

Until ;

. , Repeat Until, . , . False, , True .

Repeat :

;

False;

Begin...End.

. 0 100.

Program DemoRepeat;

Var

I, Sum: Integer;

Begin

I:=3;

Sum:=3;

Repeat

Sum:=Sum+I;

I:=I+2;

Until (I>100);

WriteLn (' ',Sum);

End.

While Repeat, .

:

While do ;

, . . True, . False, While . False, .

For, While, Repeat , .. .

. 0 100.

Program DemoWhile;

Var

I, Sum: Integer;

Begin

I:=2;

Sum:=0;

While (i<=100) do

Begin

Sum:=Sum+I;

I:=I+2;

end;

WriteLn (' ',Sum);

End.

 

7. . - Continue, Break.

Continue , , Continue.

Repeat ; Continue; ; Until ; While do begin ; Continue; ; end; For i:=1 to N do begin ; Continue; ; end;

Break , .

Repeat ; Break; ; Until ; ; While do begin ; Break; ; end; ; For i:=1 to N do begin ; Break; ; end; ;


<== | ==>
. | .
:


: 2017-02-11; !; : 484 |


:

:

: , .
==> ...

1809 - | 1415 -


© 2015-2024 lektsii.org - -

: 0.183 .