Вы находитесь на странице: 1из 11

# 7-8. .

.
,
,

..

.

,

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

,
.

;
. .
:
var
A: array[1..100] of Real

,

. ,

55

## array[boolean] of array[1..100] of Real

, :
array[boolean,1..10] of Real

, ,
.
A[5]:=3.4;
For i:=1 to 100 do
Begin
writeln( A[,I,]:);
End;

:
Const
< .>=<>;

Const N=10;
Var a:array[1..N] of real;
i:word;
sum:real;
Begin
sum:=0;
for i:=1 to N do
sum:=sum+a[i];
writeln(=,sum:10:5);
end.

56

Const N=10;
Var a:array[1..N] of real;
i:word;
p:real;
Begin
p:=1;
for i:=1 to N do
p:=p*a[i];
writeln(=,p:10:5);
end.

:
randomize;
for i:=1 to N do
a[i]:=x1+random*(x2-x1);

:
b[1]:=1;
b[2]:=1;
for i:=3 to N do
b[i]:=b[i-1]+b[i-2];

(
):
for i:=1 to N do
if b[i] mod 2=0 then
b[i]:=sqr(b[i]);

:
57

i:=2;
while i<=N do
begin
a[i]:=sqr(a[i]);
Inc(I,2);
End;

, ,
.
program rand1;
const n1=100; { }
type

## mas = array[1..n1] of integer;

var

a:mas;
i,

{ }

n,s: integer;
begin
writeln(' :');
{ }
randomize;{ }
for i:=1 to n do
a[i]:=random(10);
writeln(' ');
for i:=1 to n do
write (a[i]:5);
writeln;
s:=0; { }
for i:=1 to n do
s:=s+a[i];
writeln('s=',s);
end.

58

. n1.

, 1
100. , 1 100,
. ( ,
)
.

).

, 1
"+" "*".

,
.
program sum;
const n1=100;

{ pp }

type
mas = array[1..n1] of integer;
var
a:mas;
i,

{ }

n,s,
imax:integer;{ }
begin
writeln(' :');
{ }
for i:=1 to n do
begin

59

end;
s:=0;
imax:=1;{p, p

for i:=1 to n do
begin
{

## if a[i]>0 then s:=s+a[i];

{
, }
if a[imax]<a[i] then imax:=i;
end;
writeln(' =',a[imax]);
a[imax]:=s;{ }
writeln('s=',s);
writeln('p :');
for i:=1 to n do
writeln (a[i]);
end.

, ,
, .
.
.

1, .. ,

c ,

.
a[imax] , ,
, , ,
.
60

if a[i]>a[imax] else ; ,
imax ,
imax
.

,

. ,
array[boolean] of array[1..10] of Real;

, :
array[boolean,1..10] of Real;

. :
Matrix[I][J]

:
Matrix[I,J]

For i:=1 to N do
for j:=1 to M do
begin
writeln( a2[,I,,,j,]: );
end;

:
For i:=1 to N do
begin
for j:=1 to M do

61

write(a2[I,j]:8);
writeln;
end;

,
, .
program rand2;
const n1=10;
m1=10;
type

{o p }
{ }

## mas = array[1..n1,1..m1] of integer;

var

a: mas;
i,

{ p }

j,

{ p }

n,s,m : integer;
begin
writeln(' p :');
randomize;
for i:=1 to n do
for j:=1 to m do
a[i,j]:=random(10);
writeln(' ');
for i:=1 to n do
begin
for j:=1 to m do
write (a[i,j]:5);
writeln;
end;
s:=0;
for i:=1 to n do
for j:=1 to m do
s:=s+a[i,j];
writeln('s=',s);
end.

62

, , ,

.
,
.

i j 1 m, .. j .
, .
.
i :
,
,
.
.
.

,
.
, ,
.
. ,
,
i.
. ,
1 n,
n 1. ,
, j=n-i+1.
program diag;
const n1=10;

{o p }

type
mas = array[1..n1,1..n1] of integer;{p p}

63

var

a:mas;
i,

{ p p }

j,

{ p }

n,s:integer;
begin
writeln(' p :');
for i:=1 to n do
for j:=1 to n do
begin
writeln(' ');
end;
writeln(' ');
for i:=1 to n do
begin
for j:=1 to n do
write (a[i,j]:5);
writeln;
end;
s:=0;
for i:=1 to n do { }
s:=s+a[i,i];
writeln('s=',s);
for i:=1 to n do{ }
begin
j:=n-i+1;
if a[i,j]<0 then a[i,j]:=s;
end;
writeln(' ');
for i:=1 to n do
begin
for j:=1 to n do
write (a[i,j]:5);
writeln;
end;

64

end.

:
For i:=1 to N-1 do
for j:=1 to N-i do
begin
tmp:=c2[I,j];
c2[I,j]:=c2[N-j+1,N-i+1];
c2[N-j+1,N-i+1]:=tmp;
end;

65

## Нижнее меню

### Получите наши бесплатные приложения

Авторское право © 2021 Scribd Inc.