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
147
148
149
| program riski;
uses crt;
type mas=array[1..10] of real;
mas2=array[1..10,1..10] of real;
var a:real;m,be,bm:mas;
B,E,b1,e1:mas2;
i,k,c,v,l,j,n:integer;
mp,ebe,mbm,ebm,x,mbe:real;
procedure base;
begin
for i:=1 to n do {1}
begin
for c:=1 to n do {2} begin
for v:=1 to n do
begin
B1[c,v]:=B[c,v];
e1[c,v]:=e[c,v]; end;
end;
for k:=1 to n do
begin
B[i,k]:=B1[i,k]/b1[i,i]; {3} E[i,k]:=E1[i,k]/b1[i,i];for l:=1 to n do
begin {4}
if l<>i then
begin
B[l,k]:=(B1[l,k]-(B1[l,i]*B1[i,k]/B1[i,i])); E[l,k]:=(E1[l,k]-(B1[l,i]*E1[i,k]/B1[i,i]));
end;
end;
end;
end;for i:=1 to n do {5}
begin
for j:=1 to n do
begin
be[i]:=be[i]+e[i,j]; end;
end;
for i:=1 to n do {6}
begin
for j:=1 to n do begin
Bm[i]:=Bm[i]+m[j]*e[i,j];
end;
end;
for i:=1 to n do begin {7}
ebe:=ebe+be[i]; {8}
ebm:=ebm+bm[i];
mbm:=mbm+m[i]*bm[i];
mbe:=mbe+m[i]*be[i]; end;
end;
procedure vvod;
label out1, out2, out3, out4, out5;
var z:real; mi,ma:real;begin
writeln;
writeln(' 9');
writeln;
writeln;writeln(' 10');
writeln;
writeln(' 11');
writeln;
writeln(' 12');writeln;
writeln;
writeln;
out1:
writeln;writeln(' 13');
write(' 14 ');
readln(n);
if (n<=0) or (n<>int(n)) or (n>10) then
begin writeln(' 15 ');
goto out1;
end;
writeln;
writeln(' 16');for i:=1 to n do
begin
E[i,i]:=1;
out2:
write(' ',i,'-ого вида : '); readln(m[i]);
if (m[i]<0) then
begin
writeln(' 17 ');
goto out2; end;
end;
writeln;
writeln('18');
writeln(' 19');writeln(' 20');
writeln(' 21');
writeln;
writeln(' 22 ');
for i:=1 to n do begin
out3:
write('23 ');
readln(z);
if (z<0) then begin
writeln(' 24 ');
goto out3;
end;
b[i,i]:=z*z; end;
writeln;
writeln(' 25');
writeln(' 26');
for i:=1 to n do begin
for j:=i+1 to n do {27}
begin
out4:
write(' ',i,'-го и ',j,'-го вида: '); readln(z);
if abs(z)>=sqrt(b[i,i])*sqrt(b[j,j]) then
begin
writeln(' 28 ');
goto out4; end;
b[i,j]:=z;
b[j,i]:=z;
if i<>j then
begin E[i,j]:=0;
end;
end;
end;
writeln;ma:=0;
for i:=1 to n do
begin
if m[i]>ma then ma:=m[i];
end;mi:=100000000;
for i:=1 to n do
begin
out5:
if m[i]<ma then begin
writeln(' 29');
write(' 30 ');
goto out5;
end; end;
end;
procedure vivod;
begin
writeln;writeln(' 31');
for i:=1 to n do
begin
x:=((mbm-mp*ebm)*be[i]+(mp*ebe-mbe)*bm[i])/(ebe*mbm-mbe*mbe);
writeln(' ',i,'-го вида: ',x:6:5);if x<0 then
begin
writeln(' 32');
writeln(' 33');
writeln(' 34');end;
end;
writeln;
writeln(' Минимальный риск портфеля: ',sqrt((mp*mp*ebe-
2*mp*mbe+mbm)/(ebe*mbm-mbe*mbe)):6:5);end;
begin
clrscr;
textcolor(yellow);textbackground(blue);
vvod;
base;
vivod;
readln;end. |