Uses Crt; const n=5; m=7; type Mas = array [1..n, 1..m] of integer; var i, j, j1, j2: integer; Sumj1, Sumj2: real; A: Mas; begin ClrScr; Randomize; SumJ1:=0; SumJ2:=0; for i:=1 to n do for j:=1 to m do A[i,j]:=random (10); WriteLn (' Massiv A: '); for i:=1 to n do begin for j:=1 to m do Write (A[i,j]:4); WriteLn; end; WriteLn; repeat Write (' Stolbez #1 = '); ReadLn(j1); until (j1>=1) and (j1<=m); repeat Write (' Stolbez #2 = '); ReadLn(j2); until (j2>=1) and (j2<=m) and (j1<>j2); for i:= 1 to n do SumJ1 := SumJ1+A[i,j1]; for i:= 1 to n do SumJ2:=SumJ2+A[i,j2]; SumJ1:=SumJ1/n; SumJ2:=SumJ2/n; WriteLn; WriteLn (' Srednee stolbza ', j1, ' = ', SumJ1:4:2); WriteLn (' Srednee stolbza ', j2, ' = ', SumJ2:4:2); ReadLn; end.
Const n = 10; var a: array[1..n] of integer; i, j, t: integer; flag:boolean;
begin Randomize; Writeln('Исходный массив'); for i := 1 to n do begin a[i] := random(101)-50; Write(a[i]:4) end; Writeln; i:=1; repeat flag:=true; for j := 1 to n-i do if a[j] > a[j+1] then begin t := a[j]; a[j] := a[j+1]; a[j+1] := t; flag:=false end; Inc(i); until (i>n-1) or flag; Writeln('Отсортированный по возрастанию массив'); for i := 1 to n do Write(a[i]:4); Writeln end.
const n=5; m=7;
type Mas = array [1..n, 1..m] of integer;
var i, j, j1, j2: integer;
Sumj1, Sumj2: real;
A: Mas;
begin
ClrScr;
Randomize;
SumJ1:=0; SumJ2:=0;
for i:=1 to n do
for j:=1 to m do
A[i,j]:=random (10);
WriteLn (' Massiv A: ');
for i:=1 to n do
begin
for j:=1 to m do
Write (A[i,j]:4);
WriteLn;
end; WriteLn;
repeat
Write (' Stolbez #1 = '); ReadLn(j1);
until (j1>=1) and (j1<=m);
repeat
Write (' Stolbez #2 = '); ReadLn(j2);
until (j2>=1) and (j2<=m) and (j1<>j2);
for i:= 1 to n do
SumJ1 := SumJ1+A[i,j1];
for i:= 1 to n do
SumJ2:=SumJ2+A[i,j2];
SumJ1:=SumJ1/n; SumJ2:=SumJ2/n;
WriteLn;
WriteLn (' Srednee stolbza ', j1, ' = ', SumJ1:4:2);
WriteLn (' Srednee stolbza ', j2, ' = ', SumJ2:4:2);
ReadLn;
end.
n = 10;
var
a: array[1..n] of integer;
i, j, t: integer;
flag:boolean;
begin
Randomize;
Writeln('Исходный массив');
for i := 1 to n do
begin
a[i] := random(101)-50;
Write(a[i]:4)
end;
Writeln;
i:=1;
repeat
flag:=true;
for j := 1 to n-i do
if a[j] > a[j+1] then
begin t := a[j]; a[j] := a[j+1]; a[j+1] := t; flag:=false end;
Inc(i);
until (i>n-1) or flag;
Writeln('Отсортированный по возрастанию массив');
for i := 1 to n do Write(a[i]:4);
Writeln
end.
Тестовое решение:
Исходный массив
-32 -7 2 2 50 -33 1 31 4 -16
Отсортированный по возрастанию массив
-33 -32 -16 -7 1 2 2 4 31 50