[̲] [] [] [ ]

 

7.6.

 

, , - ' ': . (1903-1957).

:

1) ;

2) ;

3) .

, , - . , . - ( ) , .

.

,

 

----------------------

c c . .. c

1 2 n

----------------------

. ..

1 2 n

----------------------

1, 2, ..., n c1, c2, ..., cn,

 

: {c, c, ..., c } -> {, , ..., }.

1 2 n 1 2 n

 

, , , r1, r2, ..., rn; - c1, c2, ..., cm; , (rk, ci) ki

 

c c c

1 2 m

-------------------------

r . ..

1 11 12 1m

-------------------------

r . ..

2 21 22 2m

-------------------------

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

-------------------------

r . ..

n n1 n2 nm

-------------------------

 

: {r, r, ..., r } * {c, c, ..., c } -> {, , ..., }.

1 2 n 1 2 m 11 12 nm

 

, {r1, r2, ..., rn } = r1..rn {c1, c2, ..., cm} = c1..cm {r1, r2, ..., rn} = (r1, r2, ..., rn ) {c1, c2, ..., cm} = (c1, c2, ..., cm), () (), ():

 

r = succ(r ) (k=2,..., n);

k k-1

c = succ(c ) (k=2,..., m);

k k-1

r = pred(r ) (k=1,..., n-1);

k k+1

c = pred(c ) (k=1,..., m-1).

k k+1

 

.

t - , t1, ..., tn - ; Dt, Dt1,..., Dtn - . {Dt1 *... * Dtn -> Dt} Dt1 *... * Dtn Dt.

t t1, ..., tn tm,

 

------------------------------------

t = [t, ..., t ] t,

m 1 n

L-----------------------------------

 

Dtm = {Dt1 *... * Dtn -> Dt}.

 

, - , (i1,..., in ) t1, ..., tn [i1, ..., in] t.

.

 

7.5. Dt1 *... * Dtn = r Dt = k, Dtm = kr.

 

.

tm = [t1, ..., tn ] t, tm, -

tm, - t. t1, ..., tn ti.

 

1. :

- (i1, ..., in)

 

_ [ _ ]: t, t -> t.

m i

: [i, ..., i ].

1 n

 

2. :

- <- ; - tm -> tm; - , - ;

- (i1, ..., in) t

 

[i, ..., i ] <- . (7.4)

1 n

 

tm, ti, t -> tm: , (i1, ..., in) , A. - (7.4).

Tab(t1, ..., tn -> t).

. .

[1..n] n , n .

 

 

, : [1..n] .

 

Qk, :

 

Q = ;

0

Q = Q & ([k] = [k]), k=1,..., n. (7.5)

k k-1

 

, = , Qn = .

³, Q0, Q1, ..., Qn - : Qk = , i, Q0 = Q1 =...= Qi-1 = , Qi = Qi+1 =...=Qn = .

(7.5)

 

Q <- ;

k=1 n

Q <- Q & ([k] = [k])

 

, Qk

 

Q <- ; k <- 1;

(k<=n) & Q

Q <- [k] = [k]; k <- k+1

.

 

 

г (, : [1..n] ):

Q: ; k: ;

Q <- ; k <- 1;

(k<=n) & Q

Q <- [k] = [k]; k <- k+1

;

г <- Q

.

--

 

. , .

7.9. .

. sn 1, 2,..., n

 

s = 0;

0

s = s + , i = 1,..., n

i i-1 i

 

i = [i],

 

(: [1..n] ):

S: ; I: ;

S <- 0;

I<-1 n

S <- S+[i]

;

<- S

.

 

7.10.

 

n n-1

() = * + * +. .. + * +

n 0 1 n-1 n

.

. n()

 

() = (...( * + )* +...+ )* + ,

n 0 1 n-1 n

 

 

= ,

0 0

= * + , i=1,..., n.

i i-1 i

 

, , ,

 

(: [0..n] ; : ):

: ; I: ;

<- [0];

I<-1 n

<- * + [i]

;

<-

.

 

.

7.11. .

 

n

. c = S *b, cil

il j=1 ij jl

 

s <- 0;

j<-1 n

s <- s+[i,j]*[j,l]

.

 

i=1,..., m l=1,..., k.

 

(: [1..m, 1..n] ;

B: [1..n, 1..k] ):

[1..m, 1..k]

i, j, l: ; s: ;

: [1..m, 1..k] ;

i<-1 m

l<-1 k

s <- 0;

j<-1 n

s <- s + [i,j]*[j,l]

;

C[i,l] <- s

;

<-

.

 

- .

7.12. . , , .

 

( : [1..n] , : ;

k: 1..n,. : )

i: ;

<- ; i <- 0;

( Ø ) & (i<n)

i <- i+1; <- =[i];

;

k <-i k

.

 

7.7.

 

 

type t = array [t ] of t;

m i

var : t,

m

tm - ' , ti - , t - , - ' .

- ( 64Kb).

:

 

type ZNAK = array [1..255] of char;

VECT = array [1..4] of integer;

MATR = array [1..5] of VECT;

var M1: ZNAK;

M2, M4: MATR;

M3: array [1..5,1..4] of integer.

 

, M2 M3 , .

 

' . '. , .

{R+} Range checking.

 

ij .

. , , .

, M2 M3 M2:=M3, . M2:= M4 ( M4 M2).

ij .

ϳ , (') . , M1[10] M1. , , M2[3,2] M2[3][2]; n- - n .

, .

- , (. ).

 

.

4P. ( 7.9).

 

program SumVect;

const N = 10;

type MAS = array [1..N] of real;

var A: MAS;

I: integer;

function SUM (A: MAS): real;

var S: real; K: byte;

begin

S:= 0.0;

for K:=1 to N do S:= S+A[K];

SUM:= S

end;

begin

writeln(' ', N:1,' ');

for I:=1 to N do

read(A[I]);

writeln;

writeln(' A ', SUM(A))

end.

 

, , , , A: MAS;.

 

5P. ( 7.11).

 

program ProdMatr;

const N = 3; M = 2; K = 4;

type MAS= array [1..N] of real;

MAS1= array [1..K] of real;

AMAS= array [1..M] of MAS;

BMAS= array [1..N] of MAS1;

CMAS= array [1..M] of MAS1;

var A: AMAS; B: BMAS; C: CMAS;

I, J, L: integer;

procedure PROD (A: AMAS; B: BMAS; var C: CMAS);

var I, J, L: byte; S: real;

begin

for I:=1 to M do

for L:=1 to K do begin

S:= 0.0;

for J:=1 to N do S:= S+A[I,J]*B[J,L];

C[I,L]:= S

end

end;

begin

writeln(' A');

for J:=1 to M do

for I:=1 to N do begin

write('A[', J:3,', ', I:3,'] ='); readln(A[J, I])

end;

writeln(' B');

for I:=1 to N do

for J:=1 to K do begin

write('B[', I:3,', ', J:3,'] ='); readln(B[I, J])

end;

PROD (A, B, C); L:= 0;

writeln(' C: ');

for I:=1 to M do

for J:=1 to K do begin

L:= L+1; write(C[I, J]:10:3,' ');

if L mod 4= 0 then writeln

end

end.

 

6P. ( 7.12).

 

program SearchVect;

const N = 10;

type NAT = 1..N;

MAS = array [NAT] of real;

var A: MAS; X: real; K: NAT;

I: integer; T: boolean;

procedure SEARCH(A: MAS; X: real; var K: NAT; var T: boolean);

var I: byte;

begin

T:= false; I:= 0;

while (not T) and (I<N) do begin

I:= I+1; T:= X=A[I];

end;

if T then K:= I

end;

begin

write(' = '); readln(X);

writeln(' ');

for I:=1 to N do begin

write(' A[', I:3,'] ='); readln(A[I])

end;

SEARCH (A, X, K, T);

if T then begin

write(', , : ');

writeln(' A[', K:3,'] = ', X)

end

else writeln(' , ', X)

end.

 

ѳ

 

t a[n];

 

t - , a - ' , n .

0. , 0 n-1. [ni].

:

 

char m1[255];

int m2[5][4], m3[5][4];

 

' . '. , .

 

ij . .

ij .

ϳ , (') . , m1[10] m1. , , m2[3][2]; n- - n .

, .

ѳ, , - , (. ).

 

.

4C. ( 7.9).

 

#include <stdio.h>

 

/* SumVect */

 

#define n 10

 

double sum (double a[])

{

double s;

unsigned k;

 

s = 0.0;

for (k=0; k<n; k++)

s += a[k];

return s;

}

 

main()

{

double a[n];

int i;

 

printf( %u \n, n);

for (i=0; i<n; i++)

scanf(%lf, &a[i]);

printf( A %lf\n, sum(a));

}

 

. ѳ , , . , , , a[]. ( ) , b[][5].

 

5C. ( 7.11).

 

#include <stdio.h>

 

/* ProdMatr */

 

#define n 3

#define m 2

#define k 4

 

prod (double a[][n], double b[][k], double c[][k])

{

unsigned i, j, l;

double s;

 

for (i=0; i<m; i++)

for (l=0; l<k; l++)

{

s = 0.0;

for (j=0; j<n; j++)

s += a[i][j]*b[j][l];

c[i][l] = s;

}

}

 

main()

{

double a[m][n], b[n][k], c[m][k];

unsigned i, j, l;

 

printf(" A\n");

for (j=0; j<m; j++)

for (i=0; i<n; i++)

{

printf("A[%u,%u] =", j, i);

scanf("%lf", &a[j][i]);

}

printf(" B\n");

for (i=0; i<n; i++)

for (j=0; j<k; j++)

{

printf("B[%u,%u] =", i, j);

scanf("%lf", &b[i][j]);

}

prod (a, b, c);

l = 0;

printf(" C:\n");

for (i=0; i<m; i++)

for (j=0; j<k; j++)

{

l++; printf("%lf ", c[i][j]);

if (l % 4 == 0) printf("\n");

}

}

 

6C. ( 7.12).

 

#include <stdio.h>

 

/* SearchVect */

 

#define n 10

#define FALSE 0

 

search(double a[], double x, unsigned *pk, int *pt)

{

int i;

 

*pt = FALSE; i = -1;

while (!*pt && i<n-1)

{

i++; *pt = x==a[i];

}

if (*pt) *pk = i;

}

 

main()

{

double a[n], x;

unsigned i, k;

int t;

 

printf( = ); scanf(%lf, &x);

printf( \n);

for (i=0; i<n; i++)

{

printf(A[%u] = , i); scanf(%lf, &a[i]);

}

search (a, x, &k, &t);

if (t)

{

printf(, , : );

printf(A[%u] = %lf\n, k, x);

}

else printf( , %lf\n, x);

}

 

[̲] [] [] [ ]