Программа:
Pascal:
№1)
var arr: array[1..10] of integer;
begin
for var i := 1 to 10 do arr[i] := random(100);
writeln(arr);
end.
№2)
const N = 15;
var arr: array[1..N] of integer;
i, tmp: integer;
for i := 1 to 15 do arr[i] := random(100);
for i:=1 to n div 2 do begin
tmp := arr[i];
arr[i] := arr[N - i + 1];
arr[N - i + 1]:= tmp;
end;
№3)
const N = 20;
var
arr: array[1..N] of integer;
i, tmp, j: integer;
for i := 1 to N do readln(arr[i]);
for i := 1 to N - 1 do
for j := 1 to N - i do
if (arr[j] > arr[j+1]) then begin
tmp := arr[j];
arr[j] := arr[j+1];
arr[j+1] := tmp;
Программа:
Pascal:
№1)
var arr: array[1..10] of integer;
begin
for var i := 1 to 10 do arr[i] := random(100);
writeln(arr);
end.
№2)
const N = 15;
var arr: array[1..N] of integer;
i, tmp: integer;
begin
for i := 1 to 15 do arr[i] := random(100);
writeln(arr);
for i:=1 to n div 2 do begin
tmp := arr[i];
arr[i] := arr[N - i + 1];
arr[N - i + 1]:= tmp;
end;
writeln(arr);
end.
№3)
const N = 20;
var
arr: array[1..N] of integer;
i, tmp, j: integer;
begin
for i := 1 to N do readln(arr[i]);
writeln(arr);
for i := 1 to N - 1 do
for j := 1 to N - i do
if (arr[j] > arr[j+1]) then begin
tmp := arr[j];
arr[j] := arr[j+1];
arr[j+1] := tmp;
end;
writeln(arr);
end.
//c циклом for
var s,i:integer;
begin
for i:=100 to 999 do
if i mod 77 = 0 then s:=s+i;
writeln('Сумма трехзначных кратных 77: ',s);
end.
Тестовое решение:
Сумма трехзначных кратных 77: 5929
// с циклом while
var s,i:integer;
begin
i:=100;
while i<=999 do begin
if i mod 77 = 0 then s:=s+i;
i:=i+1;
end;
writeln('Сумма трехзначных кратных 77: ',s);
end.