1) program zadacha1; uses crt; var b,i,j:integer; c,pr:real; a:array [1..4,1..7] of integer;
begin clrscr; pr:=1; for i:=1 to 4 do begin for j:=1 to 7 do begin readln(a[i,j]); end; end; for i:=1 to 4 do begin for j:=1 to 7 do begin if (a[i,j] mod 3) = 0 then pr:=pr*a[i,j]; end; end; pr:=pr/3; writeln(pr:2:3); readkey; end.
2) program zadacha2; uses crt; const k=8; var b,i,j,sum:integer; c,pr:real; a:array [1..k,1..k] of integer;
begin randomize; clrscr; pr:=1; for i:=1 to k do begin for j:=1 to k do begin a[i,j]:=random(36)+10; end; end;
for i:=1 to k do begin for j:=1 to k do write(a[i,j],' '); writeln; end; for j:=1 to k do begin if (a[k,j] mod 5) = 0 then pr:=pr*a[i,j]; end;
for i:=1 to k do begin for j:=1 to k do begin if (i=j) and (a[i,j] > 0) then sum:=sum+a[i,j]; end; end;
3) program zadacha3; uses crt; const k=9; var b,i,j:integer; sred,sum,l:real; a:array [1..k,1..k] of integer;
begin randomize; clrscr; for i:=1 to k do begin for j:=1 to k do begin a[i,j]:=random(55-12+1)+12; end; end; for i:=1 to k do begin for j:=1 to k do write(a[i,j],' '); writeln; end;
for i:=1 to k do begin if (a[i,k] mod 2) = 1 then begin l:=l+a[i,k]; b:=b+1; end; end; sred:=l/b;
for i:=1 to k do begin if a[i,i]>25 then sum:=sum+a[i,i]; end; writeln;
4) program zadacha4; uses crt; const k=5; var b,i,j:integer; sred,sum,l:real; a:array [1..k,1..k] of integer;
begin randomize; clrscr; for i:=1 to k do begin for j:=1 to k do begin a[i,j]:=random(91)-20; end; end; j:=k; for i:=1 to k do begin if (a[i,j] mod 2)<> 0 then begin l:=l+a[i,j]; b:=b+1; end; j:=j-1; end; sred:=l/b;
for i:=1 to k do begin for j:=1 to k do write(a[i,j],' '); writeln; end; writeln;
writeln('Srednee ',sred:4:2); readkey; end.
5) program zadacha5; uses crt; const k=5; var b,i,j:integer; sred,sum,l:real; a:array [1..k,1..k] of integer;
begin randomize; clrscr; for i:=1 to k do begin for j:=1 to k do begin a[i,j]:=random(31)-40; end; end; j:=k; for i:=1 to k do begin if (a[i,j] mod 2)<> 0 then begin l:=l+a[i,j]; b:=b+1; end; j:=j-1; end; sred:=l/b;
for i:=1 to k do begin for j:=1 to k do write(a[i,j],' '); writeln; end; writeln;
writeln('Srednee ',sred:4:2); readkey; end.
6)
program zadacha6; uses crt; const k=6; var b,i,j:integer; sred,sum,l:real; a:array [1..k,1..k] of integer;
begin randomize; clrscr; for i:=1 to k do begin for j:=1 to k do begin a[i,j]:=random(21); end; end; j:=k; for i:=1 to k do begin if a[i,j]>5 then begin l:=l+a[i,j]; end; j:=j-1; end; l:=l/2;
for i:=1 to k do begin for j:=1 to k do write(a[i,j],' '); writeln; end; writeln;
writeln('Sum ',l:2:2); readkey; end.
7)
program zadacha7; uses crt; const k=5; var b,i,j:integer; pred,sum,l:real; a:array [1..k,1..k] of integer;
begin randomize; clrscr; for i:=1 to k do begin for j:=1 to k do a[i,j]:=random(10); end; j:=k; for i:=1 to k do begin l:=l+a[i,j]; j:=j-1; end;
for i:=1 to k do begin for j:=1 to k do write(a[i,j],' '); writeln; end;
for i:=1 to k do begin sum:=sum+a[i,i]; end; pred:=sum+l;
writeln('Sum ',pred/10:2:2); readkey; end.
8) program zadacha8; uses crt; const k=5; var b,i,j:integer; pred,sum,l:real; a:array [1..k,1..k] of integer;
begin randomize; clrscr; for i:=1 to k do begin for j:=1 to k do a[i,j]:=random(10); end; j:=k; for i:=1 to k do begin l:=l+a[i,j]; j:=j-1; end; l:=l/k; for i:=1 to k do begin for j:=1 to k do write(a[i,j],' '); writeln; end;
for i:=1 to k do begin sum:=sum+a[i,i]; end; sum:=sum/2;
Const N = 15; Var A:array[1..N] of integer; i,Kc,Kn,Sn:integer; Begin Kc:=0; Sn:=0; Kn:=0; Randomize; Write('Исходный массив:'); For i:= 1 to N do Begin A[i]:=random(21)-10; Write(' ',A[i]); if A[i] mod 2 = 0 then Kc:=Kc+1; if A[i] mod 2 <> 0 then Begin Sn:=Sn+A[i]; Kn:=Kn+1; End; if A[i]>0 then A[i]:=0; End; WriteLn; WriteLn('Количество чётных: ',Kc); WriteLn('Среднее арифметическое нечётных: ',Sn/Kn); Write('Новый массив:'); For i:= 1 to N do Write(' ',A[i]) End.
1)
program zadacha1;
uses crt;
var b,i,j:integer;
c,pr:real;
a:array [1..4,1..7] of integer;
begin
clrscr;
pr:=1;
for i:=1 to 4 do
begin
for j:=1 to 7 do
begin
readln(a[i,j]);
end;
end;
for i:=1 to 4 do
begin
for j:=1 to 7 do
begin
if (a[i,j] mod 3) = 0 then pr:=pr*a[i,j];
end;
end;
pr:=pr/3;
writeln(pr:2:3);
readkey;
end.
2)
program zadacha2;
uses crt;
const k=8;
var b,i,j,sum:integer;
c,pr:real;
a:array [1..k,1..k] of integer;
begin
randomize;
clrscr;
pr:=1;
for i:=1 to k do
begin
for j:=1 to k do
begin
a[i,j]:=random(36)+10;
end;
end;
for i:=1 to k do
begin
for j:=1 to k do
write(a[i,j],' ');
writeln;
end;
for j:=1 to k do
begin
if (a[k,j] mod 5) = 0 then pr:=pr*a[i,j];
end;
for i:=1 to k do
begin
for j:=1 to k do
begin
if (i=j) and (a[i,j] > 0) then sum:=sum+a[i,j];
end;
end;
writeln('Prozvedenie ',pr:2:2);
writeln('Summa ',sum);
writeln('Raznostb ',pr-sum:2:2);
readkey;
end.
3)
program zadacha3;
uses crt;
const k=9;
var b,i,j:integer;
sred,sum,l:real;
a:array [1..k,1..k] of integer;
begin
randomize;
clrscr;
for i:=1 to k do
begin
for j:=1 to k do
begin
a[i,j]:=random(55-12+1)+12;
end;
end;
for i:=1 to k do
begin
for j:=1 to k do
write(a[i,j],' ');
writeln;
end;
for i:=1 to k do
begin
if (a[i,k] mod 2) = 1 then
begin
l:=l+a[i,k];
b:=b+1;
end;
end;
sred:=l/b;
for i:=1 to k do
begin
if a[i,i]>25 then sum:=sum+a[i,i];
end;
writeln;
writeln('Srednee ',sred:2:2);
writeln('Summa ',sum:2:1);
readkey;
end.
4)
program zadacha4;
uses crt;
const k=5;
var b,i,j:integer;
sred,sum,l:real;
a:array [1..k,1..k] of integer;
begin
randomize;
clrscr;
for i:=1 to k do
begin
for j:=1 to k do
begin
a[i,j]:=random(91)-20;
end;
end;
j:=k;
for i:=1 to k do
begin
if (a[i,j] mod 2)<> 0 then
begin
l:=l+a[i,j];
b:=b+1;
end;
j:=j-1;
end;
sred:=l/b;
for i:=1 to k do
begin
for j:=1 to k do
write(a[i,j],' ');
writeln;
end;
writeln;
writeln('Srednee ',sred:4:2);
readkey;
end.
5)
program zadacha5;
uses crt;
const k=5;
var b,i,j:integer;
sred,sum,l:real;
a:array [1..k,1..k] of integer;
begin
randomize;
clrscr;
for i:=1 to k do
begin
for j:=1 to k do
begin
a[i,j]:=random(31)-40;
end;
end;
j:=k;
for i:=1 to k do
begin
if (a[i,j] mod 2)<> 0 then
begin
l:=l+a[i,j];
b:=b+1;
end;
j:=j-1;
end;
sred:=l/b;
for i:=1 to k do
begin
for j:=1 to k do
write(a[i,j],' ');
writeln;
end;
writeln;
writeln('Srednee ',sred:4:2);
readkey;
end.
6)
program zadacha6;
uses crt;
const k=6;
var b,i,j:integer;
sred,sum,l:real;
a:array [1..k,1..k] of integer;
begin
randomize;
clrscr;
for i:=1 to k do
begin
for j:=1 to k do
begin
a[i,j]:=random(21);
end;
end;
j:=k;
for i:=1 to k do
begin
if a[i,j]>5 then
begin
l:=l+a[i,j];
end;
j:=j-1;
end;
l:=l/2;
for i:=1 to k do
begin
for j:=1 to k do
write(a[i,j],' ');
writeln;
end;
writeln;
writeln('Sum ',l:2:2);
readkey;
end.
7)
program zadacha7;
uses crt;
const k=5;
var b,i,j:integer;
pred,sum,l:real;
a:array [1..k,1..k] of integer;
begin
randomize;
clrscr;
for i:=1 to k do
begin
for j:=1 to k do
a[i,j]:=random(10);
end;
j:=k;
for i:=1 to k do
begin
l:=l+a[i,j];
j:=j-1;
end;
for i:=1 to k do
begin
for j:=1 to k do
write(a[i,j],' ');
writeln;
end;
for i:=1 to k do
begin
sum:=sum+a[i,i];
end;
pred:=sum+l;
writeln('Sum ',pred/10:2:2);
readkey;
end.
8)
program zadacha8;
uses crt;
const k=5;
var b,i,j:integer;
pred,sum,l:real;
a:array [1..k,1..k] of integer;
begin
randomize;
clrscr;
for i:=1 to k do
begin
for j:=1 to k do
a[i,j]:=random(10);
end;
j:=k;
for i:=1 to k do
begin
l:=l+a[i,j];
j:=j-1;
end;
l:=l/k;
for i:=1 to k do
begin
for j:=1 to k do
write(a[i,j],' ');
writeln;
end;
for i:=1 to k do
begin
sum:=sum+a[i,i];
end;
sum:=sum/2;
writeln('Sum ',sum:2:2);
writeln('Sred',l:2:2);
readkey;
end.
N = 15;
Var A:array[1..N] of integer;
i,Kc,Kn,Sn:integer;
Begin
Kc:=0;
Sn:=0;
Kn:=0;
Randomize;
Write('Исходный массив:');
For i:= 1 to N do
Begin
A[i]:=random(21)-10;
Write(' ',A[i]);
if A[i] mod 2 = 0 then Kc:=Kc+1;
if A[i] mod 2 <> 0 then
Begin
Sn:=Sn+A[i];
Kn:=Kn+1;
End;
if A[i]>0 then A[i]:=0;
End;
WriteLn;
WriteLn('Количество чётных: ',Kc);
WriteLn('Среднее арифметическое нечётных: ',Sn/Kn);
Write('Новый массив:');
For i:= 1 to N do
Write(' ',A[i])
End.
Пример:
Исходный массив: -1 4 -8 9 -6 -10 0 3 9 -1 1 4 -2 -6 3
Количество чётных: 8
Среднее арифметическое нечётных: 3.28571428571429
Новый массив: -1 0 -8 0 -6 -10 0 0 0 -1 0 0 -2 -6 0