[̲] [] [] [ ]

 

7.3.

 

' . . : , , , ( ). : , , , .

. , , , , , .

 

-

 

S = {(t, s): t Î , s Î S}.

 

, , {1,6}, S {2,4,7}, - { (1,2), (6,2), (1,4), (6,4), (1,7), (6,7)}, 2*3=6 . , .

 

7.2. Ҧ=n, S=m, S=n*m.

 

n

 

... = ( ... ).

1 2 n 1 2 n

 

7.3. =m, ... =m *...* m

i i 1 n 1 n

 

(t1, (t2, (..., tn )...)

 

(t1, t2, ..., tn), (7.3)

 

(7.3) n-

 

... = {(t, t, ..., t ): t Î , i=1,2,..., n}.

1 2 n 1 2 n i i

 

- i-

 

q: ... -> ,

i 1 2 n i

 

q (t, t, ..., t ) = t, i=1,2,..., n.

i 1 2 n i

 

 

(t, t, ..., t ) = (t', t',..., t')

1 2 n 1 2 n

 

t =t', t =t',. .., t =t'.

1 1 2 2 n n

. , , .

 

t1, t2, ..., tn - ; Dt1, Dt2, ..., Dtn - ; s1, s2, ..., sn - .

 

tr t1, t2, ..., tn s1, s2, ..., sn, , , Dt1 Dt2 ... Dtn.

 

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

t =

r

s: t; s: t; ...;s: t

1 1 2 2 n n

_

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

 

_. ,

 

=

X: ; X, Y:

Y: ;

;

: ;

 

, ,

 

= (N: ; D: ).

 

, .

u, v - tr; - , tr, k - , tk.

 

1. :

-

 

_.s: t -> t , k=1,2,..., n,

k r k

 

u.sk = qk(u). , .Y .

 

2. ³:

- u = v;

 

- u <> v = Ø(u = v).

 

3. :

- u.sk <- k. , .X <- 4.7;

 

- u <- e. , Z , ,

 

Z.Y <- 2; <- Z

 

(1, 2).

 

Desc(t1, ..., tn ) , t1, ..., tn , , , .

 

7.5. :

 

=

Re: ;

Im:

;

 

X , X.Re - , X.Im - .

.

.

 

_ (X, Y: ):

Z: ;

Z.Re <- X.Re+Y.Re;

Z.Im <- X.Im+Y.Im;

_ <- Z

.

 

.

_ ( X: )

(X.Re);

X.Im >= 0 (' + ')

(' - ') ;

(X.Im,'*I')

.

 

7.6. .

 

г = ;

̳= (, , , , , , , , , , , );

= 1..31;

=

D: ;

M: ̳;

Y: г

,

 

( 7.1)

 

_̳ (M: ̳):

: ̳;

<- [, , , ];

M= _̳ <- 28

M _̳ <- 30

_̳ <- 31

,

 

 

(: ):

L: ;

L <- _̳ (.M);

 

(.M = ) & (.Y mod 4 = 0) L <- 29 ;

(.D = 31) & (.M = )

.D <- 1;

.M <- ;

.Y <- .Y+1

.Y <- .Y;

.D = L

.D <- 1;

.M <- succ(.M)

.D <- .D+1;

.M <- .M

.

7.4

 

' = 1 +2 +...+n 1, 2, ..., n, . - k, x.

7.4. k * i = Æ (k <> i), k = mk,

 

+ +...+ = m + m +...+ m.

1 2 n 1 2 n

 

', - 7.4.

 

(i) (i) (i) (i) (i) (i)

z = (s: t; s: t; ...; s: t ), i=1,2,..., n -

i 1 1 2 2 m m

i i

 

; D, D, ..., D - ; ,

z z z

1 2 n n

t t = (, , ..., ), Ï È D

1 2 n i j=1 z

j

h - t.

 

' z1, z2, ..., zn, h t, q,

 

 

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

q = h: t

|: z;

1 1

|: z;

2 2

...

|: z;

n n

;

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

 

' ,

 

 

{ } D + { } D + ... + { } D.

1 z 2 z n z

1 2 n

 

, q - , h. : k, - zk.

, , , :

- q, x.sk(i) (k = 1,2,..., mi) , x.h = i.

 

7.7. , , :

 

= C: (, )

|: (Re, Im: );

|: (R, Phi: )

;

 

(Z: ):

Z.C = <- Z.R

<- sqrt(Z.Re*Z.Re + Z.Im*Z.Im)

.

 

³, Z.C = , Z.Re Z.Im . , Z.R Z.Phi - Z.C = .

 

7.8. ³ d b, .

-

 

_ = (, );

= : _

|: (X, Y: );

|: (R, Phi: )

.

 

 

Dist (A,B: ):

A.

| : B.

| : Dist <- sqrt((A.X-B.X)*(A.X-B.X)+

(A.Y-B.Y)*(A.Y-B.Y));

| : Dist <- sqrt((A.X-B.R*cos(B.Phi))*

(A.X-B.R*cos(B.Phi))+

(A.Y-B.R*sin(B.Phi))*

(A.Y-B.R*sin(B.Phi)))

;

| : B.

| : Dist <- sqrt((A.R*cos(A.Phi)-B.X)*

(A.R*cos(A.Phi)-B.X)+

(A.R*sin(A.Phi)-B.Y)*

(A.R*sin(B.Phi)-B.Y));

| : Dist <- sqrt(A.R*A.R+B.R*B.R-2*A.R*B.R*

cos(A.Phi-B.Phi))

.

 

, ,

 

³__

_ = (, );

= : _

|: (X, Y: );

|: (R, Phi: )

.

, : ;

Dist (, : ):

...

;

 

_ ( : )

(' [, ]?:');

(A.);

(' , :');

A.

: (A.X, A.Y);

: (A.R, A.Phi)

;

(' ');

_();

(' ');

_();

('³ ', Dist(, ))

.

 

7.5.

 

- , . record end. ̳ , , ,

 

type t = record

r s: t;

1 1

s: t;

2 2

...

s: t

n n

end.

 

:

type Date= record

Day: 1..31;

Month: (jan, feb, mar, apr, may, jun,

jul, aug, sep, oct, nov, dec);

Year: 1900..3000

end;

type Avto= record

Nom: string[7]; (* *)

Marka: string[20]; (* *)

Color: 1..9; (* *)

Name: string[40]; (* *)

Adress: string[60] (* *)

end;

var M, V: Avto; D: Date;

Person: record

Name, FirstName: string[20];

BirthDate: Date;

Sex: (male, female);

MarStatus: (single, married, widowed, divorced)

end;

 

M: M.Nom, M.Marka, M.Color, M.Name, M.Adress.

- ' - . 䳿 .

. , , , M:= V , V:= D .

. with:

 

with V do

begin

end

 

V - , - . with, , , , . ,

 

with M do begin

Nom:= '53761';

Marka:= '-21';

Color:= 9;

Name:= ' ..';

Adress:= '. , 6'

end.

 

; , with .

 

2P. , ( 7.5).

 

program COMPL;

type COMPLEX= record

RE, IM: real

end;

var X, Y, Z: COMPLEX;

 

procedure GET_C (var X: COMPLEX);

begin

write('ij =? '); readln(X.RE);

write(' =? '); readln(X.IM)

end;

procedure SUMA (X, Y: COMPLEX; var Z: COMPLEX);

begin

Z.RE:= X.RE+Y.RE; Z.IM:= X.IM+Y.IM

end;

procedure PUT_C (X: COMPLEX);

begin

write(X.RE);

if X.IM>0 then write(' +') else write(' -');

write(abs(X.IM),' * I')

end;

begin

writeln(' ------ X:'); GET_C(X);

writeln(' ------ Y:'); GET_C(Y);

writeln(' ');

writeln; SUMA(X, Y, Z); PUT_C(Z)

end.

 

, , . ' , (COMPLEX).

 

. ' . case. ³ - (, , ), , . . , , . , , , (. 7.8),

 

type CoordMode= (cart, polar);

Point= record

case Syst: CoordMode of

cart: (X, Y: real);

polar: (R, Phi: real)

end.

 

:

         , ;

         , ;

         , - i, , : i: ();

         , , end.

 

3P. ³ d b ( 7.8):

 

program Distance;

type CoordMode= (cart,polar);

Point= record

case Syst: CoordMode of

cart: (X,Y: real);

polar: (R, Phi: real)

end;

var A, B: Point;

procedure Get_Point (var A: Point);

var S: byte;

begin

write(' [1- , 2- ]?: ');

readln(S);

if S=1 then A.Syst:= cart else A.Syst:= polar;

write(' : ');

case A.Syst of

cart: readln(A.X,A.Y);

polar: readln(A.R,A.Phi)

end

end;

function Dist (A,B: Point): real;

begin

case A.Syst of

cart: case B.Syst of

cart: Dist:= sqrt(sqr(A.X-B.X)+

sqr(A.Y-B.Y));

polar: Dist:= sqrt(sqr(A.X-

B.R*cos(B.Phi))+sqr(A.Y-

B.R*sin(B.Phi)))

end;

polar: case B.Syst of

cart: Dist:= sqrt(sqr(A.R*cos(A.Phi)-

B.X)+sqr(A.R*sin(A.Phi)-B.Y));

polar: Dist:= sqrt(sqr(A.R)+sqr(B.R)-

2*A.R*B.R*cos(A.Phi-B.Phi))

end

end

end;

begin

writeln(' -');

Get_Point(A);

writeln(' -');

Get_Point(B);

writeln('³ ',Dist(A,B))

end.

 

ѳ :

 

typedef struct {

t1 s1;

t2 s2;

...

tn sn;

} tr;

 

:

typedef struct {

unsigned day;

enum {jan, feb, mar, apr, may, jun, jul,

aug, sep, oct, nov, dec} month;

unsigned year;

} date;

typedef struct {

char nom[8]; (* *)

char marka[21]; (* *)

unsigned color; (* *)

char name[41]; (* *)

char adress[61]; (* *)

} avto;

date d;

avto m, v;

 

m: m.nom, m.marka, m.color, m.name, m.adress.

, - ' - . 䳿 .

 

2C. , ( 7.5).

 

#include <stdio.h>

#include <math.h>

 

/* COMPL */

typedef struct {

double re, im;

} complex;

 

get_c (complex *px)

{

printf(" =? "); scanf("%lf", &(*px).re);

printf(" =? "); scanf("%lf", &(*px).im);

}

 

suma (complex x, complex y, complex *pz)

{

(*pz).re = x.re+y.re; (*pz).im = x.im+y.im;

}

 

put_c (complex x)

{

printf("%lf", x.re);

if (x.im>0) printf(" +"); else printf(" -");

printf("%lf * I\n", fabs(x.im));

}

 

main()

{

complex x,y,z;

 

printf("------ X:\n"); get_c(&x);

printf("------ Y:\n"); get_c(&y);

printf(" \n");

suma(x, y, &z); put_c(z);

}

 

, . ' , ѳ (complex). (*pz).re , (.) , (*).

 

ᒺ ѳ ᒺ (union). ᒺ :

 

typedef union {

t1 s1;

t2 s2;

...

tn sn;

} tu;

 

tu ᒺ, t1 , ..., tn - , s1, ..., sn .

ᒺ ѳ , , ᒺ . ³ ᒺ ( ) . ᒺ ᒺ. , , , (. 7.8),

 

typedef enum {cart, polar} coord_mode;

typedef struct {

coord_mode cm;

union {

struct { double x, y;} ;

struct { double r, phi;} p;

} t;

} point;

point a, b;

 

ᒺ , , , a.cm, b.t.c.x, b.t.p.phi. , ᒺ ѳ . ᒺ .

 

3. ³ d b ( 7.8):

 

#include <stdio.h>

#include <math.h>

 

/* Distance */

 

typedef enum {cart, polar} coord_mode;

typedef struct {

coord_mode cm;

union {

struct { double x, y;} c;

struct { double r, phi;} p;

} t;

} point;

 

get_point (point *p)

{

int k;

 

printf(" [1 - , 2 - ]: ");

scanf("%d",&k);

if (k==1)

{

(*p).cm = cart;

printf(" x,y: ");

scanf("%lf %lf",&(*p).t.c.x,&(*p).t.c.y);

}

else

{

(*p).cm = polar;

printf(" r,phi: ");

scanf("%lf %lf",&(*p).t.p.r,&(*p).t.p.phi);

}

}

 

double dist (point a, point b)

{

double d;

 

switch (a.cm)

{

case cart: switch (b.cm)

{

case cart: d = sqrt((a.t.c.x-b.t.c.x)*(a.t.c.x-b.t.c.x)+

(a.t.c.y-b.t.c.y)*(a.t.c.y-b.t.c.y));

break;

case polar: d = sqrt((a.t.c.x-b.t.p.r*cos(b.t.p.phi))*

(a.t.c.x-b.t.p.r*cos(b.t.p.phi))+

(a.t.c.y-b.t.p.r*sin(b.t.p.phi))*

(a.t.c.y-b.t.p.r*sin(b.t.p.phi)));

break;

}

break;

case polar: switch (b.cm)

{

case cart: d = sqrt((a.t.p.r*cos(a.t.p.phi)-b.t.c.x)*

(a.t.p.r*cos(a.t.p.phi)-b.t.c.x)+

(a.t.p.r*sin(a.t.p.phi)-b.t.c.y)*

(a.t.p.r*sin(a.t.p.phi)-b.t.c.y));

break;

case polar: d = sqrt(a.t.p.r*a.t.p.r+b.t.p.r*b.t.p.r-

2*a.t.p.r*b.t.p.r*cos(a.t.p.phi-b.t.p.phi)

break;

}

break;

}

return d;

}

 

main()

{

point a,b;

 

printf(" 2 \n");

get_point(&a);

get_point(&b);

 

printf("³ %lf \n",dist(a,b));

}

 

[̲] [] [] [ ]