Попробуй так, заполнение отрицательными числами сделай сам, так как ща некогда искать это(может воспользоваться обчнам Random, но сделать числа отрицательными)
| Код | type Tmas_J=record J:array[1..13] of integer; Count:array[1..13] of integer; end;
Tmas_I=record I:array[1..14] of integer; Count:array[1..14] of integer; end;
var Form1:TForm1; mas:array[1..13,1..14] of integer; mas_J:Tmas_J; mas_I:Tmas_I;
procedure TForm1.FormCreate(Sender: TObject); var i, j:integer; begin Randomize; for i:=1 to 13 do for j:=1 to 14 do Mas[i,j]:=Random(501); end;
procedure TForm1.Button1Click(Sender:TObject); var ShowI, ShowJ, ShowICount, ShowJCount:string; Sum, i, j, m:integer; begin Sum:=0; ShowJ:='строках: '; ShowI:='столбцах: '; ShowICount:=' в строках: '; ShowJCount:='в столбцах: ';
for i:=1 to 13 do begin Mas_I.Count[i]:=0; Mas_J.Count[i]:=0; end; Mas_I.Count[14]:=0;
for i:=1 to 13 do for j:=1 to 14 do begin Sum:=Sum+mas[i,j]; if j =14 then begin mas_J.J[i]:=Round(Sum/14); ShowJ:=ShowJ+IntToStr(mas_J.J[i])+', '; Sum:=0; for m:=1 to 14 do if mas[i,m]>mas_J.J[i] then Inc(mas_J.Count[i]); ShowJCount:=ShowJCount+IntToStr(mas_J.Count[i])+', '; end; end;
for j:=1 to 14 do for i:=1 to 13 do begin Sum:=Sum+mas[i,j]; if i=13 then begin mas_I.I[j]:=Round(Sum/13); ShowI:=ShowI+IntToStr(Mas_I.I[j])+', '; Sum:=0; for m:=1 to 13 do if mas[m,j]>mas_I.I[j] then Inc(mas_I.Count[j]); ShowICount:=ShowICount+IntToStr(mas_I.Count[j])+', '; end; end;
ShowMessage('Среднее арифметическое: '+#13+ShowJ+#13+ShowI+#13+ 'Количестов элементов, превышающих среднее значение: '+#13+ ShowJCount+#13+ShowICount) end; | |