.


:




:

































 

 

 

 


Pascal. . , .




:

< > = array [< >] of <>,

< > - , array of , [< > - , , <> - . (!).

: type vector10 = array [1..10] of real;

: var a,b: array [1..10] of real; var a,b: vector10;

.. <> - , :

type mat = array [0..5] of array [-2..2] of real;

type mat = array [0..5, -2..2] of real; .

= :

var a,b: array [1..5] of real;

Begin

.

a:= b;

.

end.

:

for i:=1 to 5 do

Begin

if a[i]:= b[i] then

writeln( );

end;

 

, , . () (!).

:

< > = RECORD < > END

< > - , RECORD, END , < > - , ;.

Type

birthday = record birthday day, month, year, hour

day, month, year: integer; a b birthday

hour: real;

end;

var a,b: birthday;

 

, : a:= b.

, (.. , ):

a.day:= 27;

b.year:= 2000;

:

type Birthday = record

day, month, year: integer;

hour: real

end;

Var

: record

name: string;

bd: Birthday

end;

Begin

if c.bd.year = 200 then .

end.

 

, :

WITH <> DO <>

WITH, DO , <> - , ( ), <> - .

with c.bd do month:= 9;

, CASE OF. . , , . :

Type

form = record

name: string;

case byte of

0: (birthplace: string [40]);

1: (country: string [20];

entryport: string [20];

entrydate: 1..31;

exitdate: 1..31);

end;


 

11. Pascal. . : if, .

:=.

: + (), - (), * (), / (), div ( ).

mod ( 5 mod 2 = 1).

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

: not , and , or , xor .

, begin end.

:

Begin

.

Begin

.

....

end;

.

end;

 

.. end , ; . ; end , end . .

 

.

.

:

IF <> THEN <1> ELSE <2>

: <>, TRUE (), <1>, FALSE (), <2>.

:

Var var

x, y, max: integer; g,k: real;

Begin begin

if x > max then if g > 5 then

y:= max k:= k+g

else else if g = 5 then

y:= x; k:= 0

else k:= k-g;

end. end.

ELSE <2> . TRUE <1>, .

 

.

.

: CASE <_> OF <_> [ ELSE <>] END

<_> - :

<_ >: < >;

<_ > - , <_>.

: <_>, <_> , , . , . , , , ELSE. ELSE <> .

:

Program Calc;

Var

operation: Char; { }

x, y, z: real;

stop: Boolean;

Begin

stop:= false;

Repeat

wtiteln;

write(x, y =);

readln(x, y);

write(:);

readln(operation);

case operation of

+: z:= x + y;

-: z:= x - y;

*: z:= x * y;

/: z:= x / y;

Else

stop:= true;

end;

if not stop then

writeln( =', z)

Until stop

end.


12. Pascal. : for, while, repeat.

, .

1) FOR. :

FOR < >:= < > TO <> DO <>

< > - integer, < > < > - .

< >

< >:= < >. :

) < > <= >. , .

) <>.

) < > .

: { 1 N}

program sum_of_integer;

var i, N, s: integer;

Begin

write(Vvedite N);

readln(N);

s:= 0;

for i:= 1 to N do

s:= s+i;

writeln(Sum =, s)

end.

 

2) WHILE. :

WHILE <> DO <>.

<> - .

<> TRUE, <>. <> . <> FALSE, .

:

program epsilon; { }

var eps: real;

Begin

eps:= 1;

while eps/2 + 1 > 1 do

eps:= eps/2

writeln(epsilon =, eps)

end.

 

3) REPEAT..UNTIL.

REPEAT < > UNTIL <>

< > -

< > , <>: FALSE, < > , TRUE .

:

program codes_of_char; { }

var ch: char; { }

const cr = 13; { }

Begin

Repeat

readln(ch);

writeln(ch, = , ord(ch))

until ord(ch) = cr

end;

REPEAT..UNTIL BEGIN..END, UNTIL .

 

FOR, WHILE, REPEAT :

BREAK ; , .

CONTINUE . .






:


: 2016-10-27; !; : 687 |


:

:

, , . , .
==> ...

1538 - | 1378 -


© 2015-2024 lektsii.org - -

: 0.034 .