-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSTAT.PAS
138 lines (132 loc) · 2.89 KB
/
STAT.PAS
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
program STAT;
Type
Tmas = array [1 .. 3, 1 .. 70] of integer;
Tdaz = array [1 .. 3, 1 .. 100] of integer;
var
mas : Tmas;
daz : Tdaz;
procedure nuskaitymas (var mas : TMas; var daz : Tdaz);
var
f : Text;
ck : Integer;
begin
fillchar (daz, sizeof (daz), 0);
assign (f, 'stat.dat');
reset (f);
for ck := 1 to 70 do
begin
readln (f, mas [1, ck], mas [2, ck], mas [3, ck]);
inc (daz [1, mas [1, ck]]);
inc (daz [2, mas [2, ck]]);
inc (daz [3, mas [3, ck]])
end;
close (f)
end;
procedure rikiuok (r1, r2, ind : Integer; var mas : TMas);
var
v1, v2, v, pg : integer;
begin
v1 := r1;
v2 := r2;
v := mas [ind, (v1 + v2) div 2];
repeat
while mas [ind, v1] < v do inc (v1);
while mas [ind, v2] > v do dec (v2);
if v1 <= v2 then
begin
pg := mas [ind, v1];
mas [ind, v1] := mas [ind, v2];
mas [ind, v2] := pg;
inc (v1);
dec (v2)
end
until v1 > v2;
if r1 < v2 then rikiuok (r1, v2, ind, mas);
if v1 < r2 then rikiuok (v1, r2, ind, mas)
end;
procedure rasymas (var mas : Tmas; var daz : Tdaz);
var
f : text;
sum, ck : integer;
pg, v1, v2, v3 : real;
begin
assign (f, 'stat.txt');
rewrite (f);
sum := 0;
for ck := 1 to 70 do
begin
writeln (f, mas [1, ck]);
inc (sum, mas [1, ck])
end;
v1 := sum / 70;
writeln (f, 'vid ', v1 :1 :2);
pg := 0;
for ck := 1 to 70 do
pg := pg + sqr (v1 - mas [1, ck]);
writeln (f, 'disp ', pg / 70 :1 :2);
writeln (f);
sum := 0;
for ck := 1 to 70 do
begin
writeln (f, mas [2, ck]);
inc (sum, mas [2, ck])
end;
v2 := sum / 70;
writeln (f, 'vid ', v2 :1 :2);
pg := 0;
for ck := 1 to 70 do
pg := pg + sqr (v2 - mas [2, ck]);
writeln (f, 'disp ', pg / 70 :1 :2);
writeln (f);
sum := 0;
for ck := 1 to 70 do
begin
writeln (f, mas [3, ck]);
inc (sum, mas [3, ck])
end;
v3 := sum / 70;
writeln (f, 'vid ', v3 :1 :2);
pg := 0;
for ck := 1 to 70 do
pg := pg + sqr (v3 - mas [3, ck]);
writeln (f, 'disp ', pg / 70 :1 :2);
writeln (f);
sum := 0;
for ck := 1 to 100 do
if ck mod 5 = 0 then
begin
inc (sum, daz [1, ck]);
writeln (f, ck - 4, '..', ck, ' ', sum);
sum := 0;
end
else inc (sum, daz [1, ck]);
writeln (f);
sum := 0;
for ck := 1 to 100 do
if ck mod 5 = 0 then
begin
inc (sum, daz [2, ck]);
writeln (f, ck - 4, '..', ck, ' ', sum);
sum := 0;
end
else inc (sum, daz [2, ck]);
writeln (f);
sum := 0;
for ck := 1 to 100 do
if ck mod 5 = 0 then
begin
inc (sum, daz [3, ck]);
writeln (f, ck - 4, '..', ck, ' ', sum);
sum := 0;
end
else inc (sum, daz [3, ck]);
writeln (f);
close (f)
end;
begin
nuskaitymas (mas, daz);
rikiuok (1, 70, 1, mas);
rikiuok (1, 70, 2, mas);
rikiuok (1, 70, 3, mas);
rasymas (mas, daz)
end.