program task31133707; var arr: array of integer; a, valueOfNumbers, choise, k: integer; begin Writeln('ВВЕДИТЕ РАЗМЕРНОСТЬ МАССИВА: '); Readln(valueOfNumbers); SetLength(arr, valueOfNumbers); Writeln('ВВЕДИТЕ ЧИСЛО a: '); Readln(a); Writeln('КАК ЗАПОЛНИТЬ МАССИВ? СЛУЧАЙНЫМИ ЧИСЛАМИ (0) ИЛИ С КЛАВИАТУРЫ?(1)'); Readln(choise); if choise = 0 then for var i := 0 to valueOfNumbers - 1 do begin var tmpNumber := Random(valueOfNumbers + 1) + 1; if tmpNumber < a then continue else begin arr[i] := tmpNumber; Inc(k); end; end else for var i := 1 to valueOfNumbers do begin var tmpNumber := 1; Readln(tmpNumber); if tmpNumber < a then continue else begin arr[i] := tmpNumber; Inc(k); end; end; Writeln('ИСХОДНЫЙ МАССИВ: '); for var i := 1 to k do if arr[i] = 0 then continue else Write(arr[i], ' '); Writeln('КОЛИЧЕСТВО ЭЛЕМЕНТОВ МАССИВА: ', k); end.
type
intArr = array[1..10] of integer;
function isPrime(n: integer): boolean;
begin
result := False;
if n < 2 then exit;
var d := 2;
while (d <= n div 2) and (n mod d <> 0) do
d += 1;
result := d > n div 2
end;
var
a, b: intArr;
begin
Print('A:');
for var i := 1 to 10 do
begin
a[i] := i;
Print(a[i])
end;
Write(NewLine, 'B: ');
var j := 0;
for var i := 1 to 10 do
begin
if isPrime(a[i]) then
begin
j += 1;
b[j] := a[i];
Print(b[j])
end
end
end.