Во всех программах у меня будет использоваться процедура swap:
procedure swap(a: ^real; b: ^real);
var
t: real;
begin
t := a^;
a^ := b^;
b^ := t;
end;
swap(x,y) - меняет местами значения x и y.
1.
var
A: array[1..100] of real;
i, j, N: integer;
begin
readln(N);
for i := 1 to N do
read(A[i]);
for j := 1 to (N div 2) - 1 do
for i := 1 to (N div 2) - j do
swap(A[i], A[i + 1]);
for j := 1 to (N div 2) - 1 do
for i := (N div 2) + 1 to N - j do
swap(A[i], A[i + 1]);
for i := 1 to N do
writeln(A[i])
end.
2.
var
A: array[1..100] of real;
i, N: integer;
begin
readln(N);
for i := 1 to N do
read(A[i]);
for i := 1 to N - 1 do
swap(A[i], A[i + 1]);
for i := 1 to N do
writeln(A[i])
end.
3.
var
A: array[1..100] of real;
i, N: integer;
begin
readln(N);
for i := 1 to N do
read(A[i]);
for i := N downto 2 do
swap(A[i], A[i - 1]);
for i := 1 to N do
writeln(A[i])
end.
Формула нахождения НОК двух чисел A и B
1) НОК=(A*B) / НОД(A,B)
Program FindNOK;
Uses Crt;
var n,m,res,nok:integer;
function evklid( a, b: longint): longint;
begin
while (a <> 0) and (b <> 0) do
if a >= b then
a:= a mod b
else
b:= b mod a;
evklid:= a + b;
end;
begin
clrscr;
writeln('Введите A и B');
readln(M, N);
res:= (Evklid(n,m));
nok:= (m*n) div res;
writeln('NOK=',nok);
readkey;
end.
Дан АВСД-прямоуг. АВ=А; ВС=А-В
1)ВС=20-5=15
S=AB*BC=20*15=300
P=2AB+2BC=2*20+2*15=40+30=70
2) BC=12-3=9
S=12*9=108
P=2*12+2*9=24+18=42
Procedure PrintMatrix(matrix : array[,] of integer);
begin
matrix.Println;
end;