10.3.
, ( , , ). , , . .
:
- - ( );
- - ( );
- - ( 7.0);
- - - (. . ).
, , , - - - . , . , . , . ,
function Max(A: arrayt1..100] of Real): Real;
, -, :
type tArr = arrayt1..100] of Real;
function Max(A: tArr): Real;
.
10.3.1. -
- , , .
- - . - .
- , , , , .
.
procedure Inp(Max, Min: Real; N: Word);
function Mult(X, Y: Integer): Real;
- (. . 9.3), , :
Inp(Abs(Z), -Abs(T), 2 * );
M:=Mult(X + Y, X - Y);
MA:=Max(B, 5);
. . -,
type
tArr = array[1..100] of Integer;
var
Massiv: tArr;
Maxim: Integer;
:
function Max(Mas: tArr; N: Byte): Integer;
var Ma: Integer;
i: Byte;
begin
Ma := Mas[l];
for i := 2 to N do
if Ma < Mas[i] then
Ma := Mas[i];
Max := Ma
end;
, , Massiv Maxim :
Maxim : = Max(Massiv,5);</p>
, tArr. . , , .
10.3.2. -
- , . , .
- -, var. var , . . .
.
procedure MaxMin(A: tArr; var Max, Min: Real; N: Word);
Max, Min - -, N - .
- , .
- (. . 9.1). , , :
type tArr = array[1..100] of Integer;
tArr.
. . . 10.3.1, -:
function Max(var Mas: tArr; N: Byte): Integer;
var Ma: Integer;
i: Byte;
begin
Ma := Mas[l];
for i := 2 to N do
if Ma < Mas[i] then
Ma := Mas[i];
Max := Ma
end;
, , . ( , , ). , , , .
10.3.3. -
, . -. -, , (, . .), . . -. , , , . - 7.0.
- -, const. const , . . .
.
function NewString(const S: string): string;
- .
- (. . 9.3), .
- .
. . . 10.3.1 -:
function Max(const Mas: tArr; N: Byte): Integer;
var Ma: Integer;
i: Byte;
begin
Ma := Mas[l];
for i := 2 to N do
if Ma < Mas[i] then
Ma := Mas [ i ] ;
Max := Ma
end;
10.3.4.
Turbo Pascal - - . , .
.
function Equal(var Paraml, Param2; Len: Word): Boolean;
Param1, Param2 - - ( , , , -, - . .); Len - -.
, , , . 9.4, .
. . . 10.3.1, - :
function Max(var Mas; N: Byte): Integer;
type
tArray = array[1..Maxint] of Integer;
{ }
var Ma: Integer;
i: Byte;
begin
Ma := tArray(Mas)[1];
for i := 2 to N do
if Ma < tArray(Mas)[i] then
Ma := tArray(Mas)[i];
Max := Ma
end;
( ), . , .
10.3.5.
7.0 - 1 , . - 1 , , j . , - ] . High (, j . 16.1). , . , , High.
. . . 10.3.1, :
function Max(var Mas: array of Integer): Integer;
var Ma: Integer;
i: Byte;
begin
Ma := Mas[0];
for i := 1 to High(Mas) do { }
if Ma < Mas[i] then
Ma := Mas[i];
Max := Ma
end;
. , - , .
- , OpenString, string {$+} (. . 17.7.1), , - , :
procedure FillChar(var Str: OpenString; Ch: Char);
($p+)
procedure FillChar(var Str: string; Ch: Char);
10.3.6. - -
- -, . . . -, . . var.
, .
- - , : {$F+) far, , , inline interrupt.
. , .
program EXAMPLE15;
type
Func = function(X, Y: Integer): Integer;
($F+)
function Add(X, Y: Integer): Integer;
begin
Add := X + Y
end;
function Multiply(X, Y: Integer): Integer;
begin
Multiply := X * Y
end;
{$F-}
procedure PrintTable(A, B: Integer; Operation: Func);
{ }
var
i, j: Integer;
begin
for i := 1 to A do
begin
for j := 1 to do
Write(Operation(i, j): 5);
WriteLn
end;
WriteLn
end;
begin { }
PrintTable(10, 10, Add);
PrintTable(10, 10, Multiply)
end.
|