.


:




:

































 

 

 

 





, . 3 : , .

, Begin End. , .

:

Begin

1;

N;

End;

, . : If Case.

If :

1. If Then 1 { }

Else 2;

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;

ase , -. , ase , 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;

, . , for, , repeat while.

for . :

1. for _:= _ to _ do

;

2. for _:= _ downto _ do

;

. for , .

, . , . for to , for downto . for , .

: 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:= 2;

Sum:= 0;

Repeat

Sum:= Sum + I;

I:= I + 2

Until (I >100);

WriteLn ( , Sum);

End.

While Repeat, .

:

While do ;

, . . True, . False, while . False, .

For, While, Repeat , .. .

:

Break ;

Continue .


: 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.

 





:


: 2015-10-01; !; : 542 |


:

:

,
==> ...

1968 - | 1727 -


© 2015-2024 lektsii.org - -

: 0.013 .