,  ,

Pascal ABC


 
 
:  :  - 15,   - 4.87
zhumabek
1 / 1 / 0
: 25.11.2011
: 63
#1

. - Pascal ABC

09.12.2011, 16:31. 1840. 1
( )

1. . .
2. () .
0
? .
Similar
41792 / 34177 / 6122
: 12.04.2006
: 57,940
09.12.2011, 16:31
! . (Pascal ABC):

**. - Pascal ABC
**. .

- Pascal
. .

: - Pascal
! : ? ...

z=p-q, p q - , A(3,3) B(4,4). - Pascal
!! z=p-q, p q - , ...

- Pascal
. .

- Pascal
: 3x3. - + . ...

1
GoldenBoy
Goldeeeeeeen !
242 / 234 / 75
: 15.10.2011
: 457
09.12.2011, 18:00 #2
2.

Pascal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{Èç ñâîéñòâ îïðåäåëèòåëÿ èçâåñò*î, ÷òî îïðåäåëèòåëü ì*òðèöû ïîðÿäê* N ìîæåò áûòü ïðåäñò*âëå* â âèäå ñóììû N îïðåäåëèòåëåé N-1 ïîðÿäê* (ð*çëîæå*èå ïî ñòðîêå èëè ñòîëáöó). Ïðåäïîëîæèì ìû ð*ñêë*äûâ*åì ïî ïåðâîìó ñòîëáöó. Ïðè ýòîì îïðåäåëèòåëü ð*âå* ñóììå ïðîèçâåäå*èé ýëåìå*òîâ ýòîãî ñòîëáö* ** ìè*îð ä***îãî ýëåìå*ò* ì*òðèöû è ** -1 â ñòåïå*è ñóììû è*äåêñîâ ýëåìå*ò*. Ìè*îð ýëåìå*ò* *[i,j] ì*òðèöû - ýòî îïðåäåëèòåëü ì*òðèöû, ïîëó÷å**îé âû÷åðêèâ**èåì i-òîé ñòðîêè è j-òîãî ñòîëáö*.}
const n=3; { ð*çìåð*îñòü ì*òðèöû }
type matr=array[1..n,1..n] of longint;
var a,b:matr;
    i,j,dt:longint;
procedure PrintMatr(m:matr;n:integer);
{ ïðîöåäóð* âûâîä* ì*òðèöû ** ýêð** }
var i,j:integer;
  begin
  for i:=1 to n do
    begin
    for j:=1 to n do
      write(m[i,j]:3);
    writeln;
    end;
  end;
procedure GetMatr(a:matr; var b:matr; m,i,j:integer);
{ Âû÷åðêèâ**èå èç ì*òðèöû ñòðîêè è ñòîëáö* }
var ki,kj,di,dj:integer;
  begin
  di:=0;
  for ki:=1 to m-1 do
    begin
    if (ki=i) then di:=1;
    dj:=0;
    for kj:=1 to m-1 do
      begin
      if (kj=j) then dj:=1;
      b[ki,kj]:=a[ki+di,kj+dj];
      end;
    end;
  end;
Function Determinant(a:matr;n:integer):longint;
{ Âû÷èñëå*èå îïðåäåëèòåëÿ ì*òðèöû }
var i,j,d,k:longint;
    b:matr;
  begin
  d:=0; k:=1;
  if (n<1) then
    begin
    writeln('Determinant: Cann''t run. N=',n); halt;
    end;
  if (n=1)
    then d:=a[1,1]
  else if (n=2)
    then d:=a[1,1]*a[2,2]-a[2,1]*a[1,2]
  else { n>2 }
    for i:=1 to n do
      begin
      GetMatr(a,b,n,i,1);
      {writeln('i=',i,' a[',i,',1]=',a[i,1]);
      PrintMatr(b,n-1);}
      d:=d+k*a[i,1]*Determinant(b,n-1);
      k:=-k;
      end;
  Determinant:=d;
  end;
begin
{ Ç*ïîë*å*èå ì*òðèöû ñëó÷*é*ûìè ÷èñë*ìè }
randomize;
for i:=1 to n do
for j:=1 to n do
  a[i,j]:=random(5);
{ Ïå÷*òü èñõîä*îé ì*òðèöû }
PrintMatr(a,n);
{ Âû÷èñëå*èå è âûâîä îïðåäåëèòåëÿ }
dt:=Determinant(a,n);
writeln('=========');
writeln('Determinant=',dt);
end.
2
1.

Pascal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
program SumMatrix;
const
  MAXCOUNT = 30; {ì*êñèì*ëü**ÿ ð*çìåð*îñòü ì*òðèöû}
type
  {ïðÿìîóãîëü**ÿ ì*òðèö*}
  Matrix = array [1..MAXCOUNT, 1..MAXCOUNT] of real;
var
  matr1, matr2: Matrix; {èñõîä*ûå ì*òðèöû}
  resmatr: Matrix; {ì*òðèö*-ðåçóëüò*ò}
  n, m: integer; {ðå*ëü*ûå ð*çìåð*îñòè ì*òðèö}
  min, max: real; {ãð**èöû äè*ï*çî** ñëó÷*é*ûõ ÷èñåë}
  ask: char; {äëÿ ââîä* ðåæèì*}
 
(*----------------------------------------
Ââîä ð*çìåð*îñòåé ì*òðèöû
----------------------------------------*)
procedure EnterMatrixSize(var x,y: integer);
begin
  {ñòðîêè}
  repeat
  write('Ââåäèòå êîëè÷åñòâî ñòðîê ì*òðèö (1..',MAXCOUNT,') ');
  readln(x);
  if (x<1) then
  writeln('Îøèáê*! Ð*çìåð*îñòü ì*òðèö *å ìîæåò áûòü '+
  'ìå*üøåé åäè*èöû. Ïîâòîðèòå ââîä.');
  if (x>MAXCOUNT) then
  writeln('Îøèáê*! Ð*çìåð*îñòü ì*òðèö *å äîëæ** áûòü '+
  'áîëüøåé ',MAXCOUNT,'. Ïîâòîðèòå ââîä.');
  until (x>0)and(x<=MAXCOUNT);
  {ñòîëáöû}
  repeat
  write('Ââåäèòå êîëè÷åñòâî ñòîëáöîâ ì*òðèö (1..',MAXCOUNT,') ');
  readln(y);
  if (y<1) then
  writeln('Îøèáê*! Ð*çìåð*îñòü ì*òðèö *å ìîæåò áûòü '+
  'ìå*üøåé åäè*èöû. Ïîâòîðèòå ââîä.');
  if (y>MAXCOUNT) then
  writeln('Îøèáê*! Ð*çìåð*îñòü ì*òðèö *å äîëæ** áûòü '+
  'áîëüøåé ',MAXCOUNT,'. Ïîâòîðèòå ââîä.');
  until (y>0)and(y<=MAXCOUNT);
end;
 
(*----------------------------------------
Ïîýëåìå*ò*ûé ââîä ïðÿìîóãîëü*îé ì*òðèöû ñ êë*âè*òóðû
----------------------------------------*)
procedure EnterMatrix (x,y: integer; var M: Matrix);
var
  i,j: integer;
begin
  writeln('Ââåäèòå ýëåìå*òû ïðÿìîóãîëü*îé ì*òðèöû:');
  for i:=1 to x do
  for j:=1 to y do begin
  write('M[',i,',',j,'] = ');
  readln(M[i,j]);
  end;
end;
 
(*----------------------------------------
Ãå*åð*öèÿ ñëó÷*é*ûõ ýëåìå*òîâ ì*òðèöû â
ç*ä***îì äè*ï*çî*å
----------------------------------------*)
procedure GenerateMatrix (x,y: integer; var M: Matrix);
var
  i,j: integer;
begin
  for i:=1 to x do
  for j:=1 to y do
  M[i,j] := random*(max-min)+min;
end;
 
(*----------------------------------------
Ïîýëåìå*ò*ûé âûâîä ì*òðèöû ** ýêð** â
"åñòåñòâå**îì" âèäå (ò.å. ïî ñòðîê*ì)
----------------------------------------*)
procedure PrintMatrix(x,y: integer; M: Matrix);
var
  i,j: integer;
begin
  for i:=1 to x do begin
  for j:=1 to y do
  write(M[i,j]:6:2);
  writeln;
  end;
end;
 
(*----------------------------------------
Ïðîöåäóð* ïåðåì*îæ*åò äâå ïðÿìîóãîëü*ûå
ì*òðèöû ïî ôîðìóëå ëè*åé*îé *ëãåáðû.
Ðåçóëüò*ò - òðåòüÿ ì*òðèö*
----------------------------------------
Ð*çìåð*îñòè ì*òðèö: m1(n,m), m2(m,n), res(n,n)
----------------------------------------*)
procedure MulOfMatrix(m1, m2: Matrix; var res: Matrix; n, m: integer);
var
  i, j, k: integer;
begin
  for i:=1 to m do
  for j:=1 to m do begin
  res[i,j]:=0;
  for k:=1 to n do
  res[i,j] := m1[i,k]*m2[k,j];
  end;
end;
 
{îñ*îâ**ÿ ïðîãð*ìì*}
begin
  writeln('Ïðîãð*ìì* ïåðåì*îæ*åò äâå '+
  'ïðÿìîóãîëü*ûå ì*òðèöû');
  EnterMatrixSize(n,m);
  {ìå*þ ðåæèìîâ}
  writeln('Âûáåðèòå â*ðè**ò ç*ïîë*å*èÿ ì*òðèö:');
  writeln('1 - ñ êë*âè*òóðû');
  writeln('2 - ñëó÷*é*ûìè ÷èñë*ìè');
  repeat
  readln(ask);
  if (ask<>'1')and(ask<>'2') then
  writeln('Âûáåðèòå ðåæèì 1 èëè 2, ïîæ*ëóéñò*');
  until (ask='1')or(ask='2');
  case (ask) of
  '1': begin
  writeln('Ââåäèòå ýëåìå*òû ïåðâîé ì*òðèöû');
  EnterMatrix(n, m, matr1);
  writeln('Ââåäèòå ýëåìå*òû âòîðîé ì*òðèöû');
  EnterMatrix(m, n, matr2);
  end;
  '2': begin
  randomize;
  write('Ââåäèòå *èæ*þþ ãð**èöó äè*ï*çî** ñëó÷*é*ûõ ÷èñåë: ');
  readln(min);
  write('Ââåäèòå âåðõ*þþ ãð**èöó äè*ï*çî** ñëó÷*é*ûõ ÷èñåë: ');
  readln(max);
  GenerateMatrix(n, m, matr1);
  GenerateMatrix(m, n, matr2);
  end;
  end;
  writeln('Ïåðâ*ÿ èñõîä**ÿ ì*òðèö*:');
  PrintMatrix(n, m, matr1);
  writeln('Âòîð*ÿ èñõîä**ÿ ì*òðèö*:');
  PrintMatrix(m, n, matr2);
  {ñ÷èò*åì è âûâîäèì}
  MulOfMatrix(matr1, matr2, resmatr, n, m);
  writeln('Ì*òðèö*-ðåçóëüò*ò ïîýëåìå*ò*îãî ñëîæå*èÿ:');
  PrintMatrix(n, n, resmatr);
  writeln('Í*æìèòå [Enter] äëÿ ç*âåðøå*èÿ ïðîãð*ììû');
  readln;
end.
1
MoreAnswers
37091 / 29110 / 5898
: 17.06.2006
: 43,301
09.12.2011, 18:00
! :

- Pascal
. , ...

- Pascal ABC
n*m m*k. .

- Pascal
Pascale. . 3 . ...

- Pascal
, , ,




:
2

- , ,
-
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
@Mail.ru