.


:




:

































 

 

 

 


.




18-19

 

- .

:,,,. .

- .
. - . ( )
, . - . . ( )

, , .

-1-3-5-6-8-9-10-11

-4-9

-7-9

 

 

1.. . .

p p p , .

:

1.

2. p (, ) p p p p p ( p p) ().

3. p p p , p.

4. P , p p p .

5. . p p pp .

.

( );

( );

( ;

( ).

.

.

, .

21

- , - , ( ) , . . :

- (. 1.1). : "" ("").

- (. 1.2). : "" ("" "") () .

 

1 2

 

 

(. 1.3). : .

(. 1.4). : . () . , "+", , "".

 

3 4

 

,.

23

, .. , , , . , , , . , .

 

 

, , , .

.

, . ( ) , , .

, . , ( ) .

, , , -.

. , ,

, .. , Word, Byte ( ), LongInt Integer, , , ShortInt.

, ,- , ( ). , .

. FALSE () TRUE ().

, .

. CHAR 1 . . 0255. .

ASCII (American Standart Code for Information Interchange ). 7- , .. 128 0 127. 8- , , 0 255. 0127 ASCII. 128255 .

031 . , .

. , . , ,

Type Colors = (red, white, blue);

 

: 0, 1 .. 65536 , WORD 0,1 ..

, , .

-. - , , -.

- :

<..>..<..>

<..> - -.

<..> - .

Type

Digit = 0..9;

Dig2 = 48.. 57;

- :

1. .. , .

2. .

- , , .

, , , , , .

24

Turbo Pascal.

1. IF...THEN....ELSE (......) , :

IF THEN 1

ELSE 2;

, 1. 2.

 

2. FOR...TO...DO.

: for i:=A to B do S, i- ( ) integer, A B (B>A) integer, S- ( ). A>B, S ( i ). i , A B TO, i , DOWNTO A>B.

3. WHILE...DO.

while () do

begin

( )

end;

4. REPEAT...UNTIL.

, , . . ().

:

REPEAT < > UNTIL <>, < > Turbo Pascal, <> - . REPEAT...UNTIL :

REPEAT

Instruction1;

Instruction2;

.............

InstructionM;

UNTIL S;

Instruction1, Instruction2,..., InstructionM , , S- , .

25

- . , -, Assign. , (, , ..). / . -. Turbo Pascal 3 : ( Text),

(file of <>) (file). . . Seek . . , , Close. , . -. ( {$I+}), , ( {$I-}), - IOResult.

26

. . , . , . ( ):

() : +, -, not.

: *, /, div, mod, and.

: +, -, or, xor.

: <, <=, >, >=, =, <>.

Pascal

1.

- , .

- :

Begin

...

Begin

...

Begin

...

End;

End;

End;

; End - .

2.

IF <> THEN <1> [ELSE <2>]

BOOLEAN . , , , THEN, ELSE, .

, ELSE "" THEN.

:

Var

A, B, C, D: Integer;

begin

A:=1;

B:=2;

C:=3;

D:=4;

If A > B Then

If C < D Then

If C < 0 Then

C:=0

{ , Else}

{ ";" }

Else

A:=B;

end.

:

If A > B Then

If C < D Then

If C < 0 Then

C:=0

Else

Else

Else A:=B

 

, 0 15 :

Program Hex;

Var

Ch: Char;

N: Integer;

Begin

Write ('N = ');

Readln(N);

If (N >= 0) And (N <= 15) Then

Begin

If N < 10 Then

Ch:= Chr(Ord('0')+N)

Else

Ch:=Chr(Ord('A')+N-10);

End

Else

Writeln('');

End.

3.

.

For < >:=< > To(DownTo) < > Do < >

. 1. to, , downto .

. , For . 1 :

Program Summa;

Var

I, N, S: Integer;

Begin

Write('N = ');

Readln(N);

S:=0;

For I:=1 To N Do

S:=S + I;

Writeln ('C = ', S)

End.

.

While <> Do < >

, true. , , ( DOS ). , .

"" Real:

Program Epsilondetect;

Var

Epsilon: Real;

Begin

Epsilon:=1;

While Epsilon + 1 > 1 Do

Epsilon: = Epsilon/2;

Writeln (' = ', Epsilon);

End.

.

Repeat < > Until <>

. , true.

: ASCII - , :

Program Code;

Const

Cr = 13;

Var

Ch:Char;

Begin

Repeat

Readln (Ch);

Writeln (Ch,' = ', Ord (Ch));

Until Ord (Ch) = Cr

End.

 

.

Case < > Of < > Else <> End;

< > - ,

< > - < >:< >.

, . : , , - .

2 2

*

, +, -, /, *.

:

Program Calc; Var

Operation: Char; { }

X, Y, Z: Real;

Stop: Boolean;

Begin

Stop:= False;

repeat

Writeln; { - }

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 = ',Z);

Until Stop;

End.

, , .

.

Goto <>

, . , () , () .

27

Turbo Pascal.

, .

.

, , , , .. , . array of ( ).

, , . , , < >: = array [< >] of < >;

[I], , I (0<=I<=N, 1<=I<=N) A[I] - .

. "", " " . , , , . . .

, () .

, . , , for, while, repeat, Read, Readln, Write, Writeln; , .

, . A(I,J), , I () , J () .

:

>: array [< >] of array [< >] of < >;

< >: array [< >,< >] f < >].

 

.

, . , . 100 ? ? .

 

. () . , . , () .

, . , . , , .

, , . . , ( Pascal ). .

, . . , integer, real.

, , . .. , , . , , .

, . . . .

.

 

const n = 200;

type

months = (jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec);

years = 1900..2100;

people = array[years] of longint;

var

growth: array[months] of real;

hum: people;

notes: array[1..n] of string;

 

.

. .

var ch: array [1..11] of char;

h: char;

i: integer;

 

begin

for i:= 1 to 11 do read (ch[i]);

 

for i:= 1 to 11 do write (ch[i]:3);

 

readln

end.

11 . 1 11. 11 (, q, w, e, 2, t, 9, u, I, I, o, p), . i for . for .

, , , . , .. , . .

Var A: array [1..10] of integer;

I: byte; { I }

Begin

For i:=1 to 10 do Readln (a[i]); { i- }

 

 

, , random(N).

 

Var A: array [1..10] of integer;

I: byte; { I }

Begin

For i:=1 to 10 do A [ i ]:= random (10); { i - 0 10}

, , , .

Var A: array [1..10] of integer;

I: byte; { I }

Begin

For i:=1 to 10 do Write (a [ i ], ); { , }

. , , .. , .

Var A: array [1..10] of integer;

I: byte; { I }

Begin

For i:=1 to 10 do Writeln (a[, i,]=, a[i]); { }

, , :

 

a[1]=2

a[2]=4

a[3]=1 ..

28

, .

.

, , , , .. , . array of ( ).

, , . , , < >: = array [< >] of < >;

[I], , I (0<=I<=N, 1<=I<=N) A[I] - .

. "", " " . , , , . . .

, () .

, . , , for, while, repeat, Read, Readln, Write, Writeln; , .

, . A(I,J), , I () , J () .

:

>: array [< >] of array [< >] of < >;

< >: array [< >,< >] f < >].

, . . , , , . . .

Pascal :

array [1..m, 1..n] of _

-:

array [1..m] of array [1..n] of _

type , . . m n , , . , 1 m , 1 n .

1 type:

const

M = 10;

N = 5;

type

matrix = array [1..M, 1..N] of integer;

var

a: matrix;

 

2 :

const

M = 10;

N = 5;

var

a: array [1..M, 1..N] of integer;

 

( ), :

type a = array[1..10] of byte;

var b: array[1..100] of a;

 

( , ), (, a[i,2]:=6). Pascal (, a[i][5]:= 7).

, . ( ):

type

arr = array[1..4, 1..3] of integer;

const

cords: arr = ((1,-1,3), (0,0,0), (1,4,0), (4,-1,-1));

. , .

var

matrix: array[1..3,1..5] of integer;

i, j: integer;

begin

writeln (' 15 : ');

for i:= 1 to 3 do

for j:= 1 to 5 do

read (matrix[i,j]);

 

for i:= 1 to 3 do begin

for j:= 1 to 5 do

write (matrix[i,j], ' ');

writeln

end;

 

readln

end.

 

(.. ) . 15 .

, read i j. i , j , , , . i , j . . for 15 , 3.

. , .

. 3 5 . .

, . 3 5. ? (, ) . . . .

, (, .. ). .

:

const

M = 3;

N = 5;

var

matrix: array[1..M,1..N] of integer;

i, j: integer;

begin

writeln (' 15 : ');

for i:= 1 to M do

for j:= 1 to N do

read (matrix[i,j]);

 

for i:= 1 to M do begin

for j:= 1 to N do

write (matrix[i,j]:5);

writeln

end;

readln

end.

 

29

, . : ; ; , - . .. . :

int i[2][4] = {{1,2,3,4}, {5,6,7,8}};

.. 24. .. 2 4 .

, . , :

#include <conio.h>

#include <stdio.h>

int main()

int arr[2][4];

for (int i = 0; i < 2; i++){

for (int j = 0; j < 4;j++){

scanf ("%d", &arr[i][j]);

for (int i = 0; i < 2; i++){

for (int j = 0; j < 4;j++){

printf ("%d ", arr[i][j]);

printf ("\n");

getch();

return 0;

. , - , - ( ).

, arr[2][4], arr[7][6]. , , . .

/C++ define. :

#include <conio.h>

#include <stdio.h>

#define SIZE_A 2

#define SIZE_B 2

int main()

int arr[SIZE_A][SIZE_B];

for (int i = 0; i < SIZE_A; i++){

for (int j = 0; j < SIZE_B;j++){

scanf ("%d", &arr[i][j]);

for (int i = 0; i < SIZE_A; i++){

for (int j = 0; j < SIZE_B;j++){

printf ("%d ", arr[i][j]);

printf ("\n");

getch();

 

return 0;

.. , .

. :

void printArr (int arr[][2]){ //; }

, . , , :

printArr(arr);

, . .

:

, , . , ,

44. (11,..., 44)

, .

- 4- , , . 1 (8 ) 4 (32 ) . , 4 , .

: - , ASCII, ASCII.

:

4- . . . "pack":

0111 0000 0110 0001 0110 0011 0110 1011

, ?

:

0-255

ASCII

 

 

:

255

ASCII

AMXX ?

. () , . , / .

:

public strpack(const s_Unpacked[], s_Packed[])

new i

while((s_Packed{i} = s_Unpacked[i++])) {}

public strunpack(const s_Packed[], s_Unpacked[])

new i

while((s_Unpacked[i] = s_Packed{i++})) {}

'char' . '!' .

:

:

new s_String[11 char] =!"The string"

, [] {}.

:

 

:

= s_String[5]

= s_String{5}

?

, . . , . :

:

#defined PACKED_STRINGS

:

#include <amxmodx>

#define PLUGIN "Packed vs Unpacked"

#define VERSION "1.0"

#define AUTHOR "bugsy"

#define PACK_STRINGS

#define NUM_STRINGS 20

#define MAX_STRING_SIZE 512

#if defined PACK_STRINGS

new g_szUnpackBuffer[MAX_STRING_SIZE];

new g_szStrings[NUM_STRINGS][MAX_STRING_SIZE char]

#else

new g_szStrings[NUM_STRINGS][MAX_STRING_SIZE]

#endif

public plugin_init()

register_plugin(PLUGIN, VERSION, AUTHOR)

public plugin_cfg()

for (new iTest = 0; iTest < NUM_STRINGS; iTest++)

#if defined PACK_STRINGS

g_szStrings[iTest] =!"Packed strings"

strunpack(g_szStrings[iTest], g_szUnpackBuffer);

server_print("%d = %s", iTest, g_szUnpackBuffer);

#else

g_szStrings[iTest] = "Unpacked strings";

server_print("%d = %s", iTest, g_szStrings[iTest]);

#endif

#if defined PACK_STRINGS

public strunpack(szPacked[], szUnpacked[])

new i;

while((szUnpacked[i] = szPacked{i++})){}

#endif

30

- , 70- XX .

, :

, ;

, ;

, ( .

, .

( , ) ( ). . , .

, " ". , , . , , "", . . , , ( ), -"" , , . , "", . , , . , , , . , - , .

- , . , .

:

;

;

.

. , .

. .

. .

, .

, . . , , . , - .

- . .

:

Pascal-Urok13-1

, , . , , .

, , . , , .

var, - , . var, - , .

, (. . ) . , . .

, ( ). - .

- . - .

.

- , .

- , . . , , , .

: () . . .

 

, . . . . , Read(F) F, Delay(5) 5 .

, : ; . , Chr(65) ( ASCII 65), Sqr(X) X X.

, - - , , , , , , .

: () . . . , .





:


: 2016-10-06; !; : 910 |


:

:

, , 1:10
==> ...

1630 - | 1551 -


© 2015-2024 lektsii.org - -

: 1.223 .