1)
var
a:array [1..15] of integer;
s,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(80)-20;
write (a[i],' ');
s:=s+a[i];
end;
writeln;
writeln ('Summa = ',s);
readln;
end.
2)
var
a:array [1..15] of integer;
i:integer;
p:longint;
begin
randomize;
p:=1;
for i:=1 to 15 do begin
a[i]:=random(26)+5;
write (a[i],' ');
p:=p*a[i];
end;
writeln;
writeln ('Proizvedenie = ',p);
readln;
end.
3)
var
a:array [1..15] of integer;
k,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(90)-50;
write (a[i],' ');
if a[i]<0 then k:=k+1;
end;
writeln;
writeln ('Kol-vo = ',k);
readln;
end.
4)
var
a:array [1..15] of integer;
k,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(37)+1;
write (a[i],' ');
if odd(a[i])=true then k:=k+1;
end;
writeln;
writeln ('Kol-vo = ',k);
readln;
end.
5)
var
a:array [1..15] of integer;
k,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(39)+2;
write (a[i],' ');
if a[i]<20 then k:=k+1;
end;
writeln;
writeln ('Kol-vo = ',k);
readln;
end.
6)
var
a:array [1..15] of integer;
k,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(60)+5;
write (a[i],' ');
if a[i] mod 7 = 0 then k:=k+1;
end;
writeln;
writeln ('Kol-vo = ',k);
readln;
end.
7)
var
a:array [1..15] of integer;
s,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(8)+3;
write (a[i],' ');
if a[i]=8 then s:=s+a[i]
end;
writeln;
writeln ('Summa = ',s);
readln;
end.
8)
var
a:array [1..15] of integer;
s,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(69)+5;
write (a[i],' ');
if a[i] mod 11 = 0 then s:=s+a[i];
end;
writeln;
writeln ('Summa = ',s);
readln;
end.
9)
var
a:array [1..15] of integer;
s,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(69)+5;
write (a[i],' ');
if odd(a[i])=false then s:=s+a[i];
end;
writeln;
writeln ('Summa = ',s);
readln;
end.
10)
var
a:array [1..15] of integer;
i:integer;
p:longint;
begin
randomize;
p:=1;
for i:=1 to 15 do begin
a[i]:=random(69)+5;
write (a[i],' ');
if a[i] mod 3 = 0 then p:=p*a[i];
end;
writeln;
writeln ('Proizvedenie = ',p);
readln;
end.
14)
var
a:array [1..15] of integer;
i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(26)+5;
write (a[i],' ');
end;
writeln;
writeln ('');
for i:=1 to 15 do
if odd(a[i])=false then write (a[i],' ');
readln;
end.
13)
var
a:array [1..15] of integer;
k,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(85)+21;
write (a[i],' ');
end;
writeln;
writeln('');
for i:=1 to 15 do
if a[i] mod 21 = 0 then begin
write (a[i],' ');
k:=k+1;
end;
if k=0 then writeln ('Elementov net');
readln;
end.
12)
var
a:array [1..15] of integer;
k,i:integer;
begin
randomize;
for i:=1 to 15 do begin
a[i]:=random(37)+1;
write (a[i],' ');
end;
writeln;
writeln('');
for i:=1 to 15 do
if a[i]>15 then write (a[i],' ');
readln;
end.
11)
var
a:array [1..15] of integer;
i:integer;
p:longint;
begin
randomize;
p:=1;
for i:=1 to 15 do begin
a[i]:=random(15)+1;
write (a[i],' ');
if (a[i]>2) and (a[i]<5) then p:=p*a[i];
end;
writeln;
writeln ('Proizvedenie = ',p);
readln;
end.
Поделитесь своими знаниями, ответьте на вопрос:
Влинейном массиве целых чисел удалить элемент массива равный квадрату 5 элемента .если таких элементов нет, то выдать сообщение элементы для удаления не найдено
N = 10;
Var
A:array[1..N] of integer;
i,k:integer;
Begin
Randomize;
Write('Исходный массив:');
For i:= 1 to N do
Begin
A[i]:=random(5);
Write(' ',A[i]);
End;
k:=0;
WriteLn;
For i:= 1 to N do
if i <> 5 then
if A[i] = A[5]*A[5] then k:=i;
if k = 0 then WriteLn('Таких элементов не найдено')
else
Begin
Write('Новый массив: ');
For i:= k to N-1 do
A[i]:=A[i+1];
For i:= 1 to N-1 do
Write(' ',A[i])
End;
ReadLn
End.