program raf105;
var
a, s: real;
function square(a: real): real;
begin
square:= a*a;
end;
write('Введите сторону квадрата: ');
readln(a);
s:= square(a);
writeln('Его площадь равна ',s);
end.
num10, num2, count_1: integer;
write('Введите десятичное число: ');
readln(num10);
repeat
if (num10 mod 2 = 1) then
count_1:= count_1 + 1;
num10:= num10 div 2;
if num10 = 1 then
inc(count_1)
until num10 <= 1;
writeln('В двоичной записи числа ',count_1,' ед.');
const
n=10;
type
massive = array [1..n] of integer;
procedure select(mas : massive);
i, j, k,tmp: integer;
for i:=1 to n-1 do
k:=i;
tmp:=mas[i];
for j:=i+1 to n do
if (mas[j]<tmp) then
k:=j;
tmp:=mas[j];
mas[k]:=mas[i];
mas[i]:=tmp;
write('Сортировка выбором:');
for i:=1 to n do
write(' ',mas[i],', ');
procedure bubble (mas : massive);
i,j,tmp:integer;
for j:=1 to n-i do
if (mas[j]>mas[j+1]) then
mas[j]:=mas[j+1];
mas[j+1]:=tmp;
write('Сортировка пузырьком:');
procedure insert(mas : massive);
i,j,k,tmp : integer;
for i:=2 to n do
j:=1;
while (tmp>mas[j]) do
j:=j+1;
for k:=i-1 downto j do
mas[k+1]:=mas[k];
mas[j]:=tmp;
write('Сортировка вставкой:');
i : integer;
a : massive;
randomize;
write('Массив:');
a[i]:=random(100);
write(a[i]:4);
writeln;
select(a);
bubble(a);
insert(a);
program raf105;
var
a, s: real;
function square(a: real): real;
begin
square:= a*a;
end;
begin
write('Введите сторону квадрата: ');
readln(a);
s:= square(a);
writeln('Его площадь равна ',s);
end.
2.program raf105;
var
num10, num2, count_1: integer;
begin
write('Введите десятичное число: ');
readln(num10);
repeat
if (num10 mod 2 = 1) then
count_1:= count_1 + 1;
num10:= num10 div 2;
if num10 = 1 then
inc(count_1)
until num10 <= 1;
writeln('В двоичной записи числа ',count_1,' ед.');
end.
PascalABC 3.4.2const
n=10;
type
massive = array [1..n] of integer;
procedure select(mas : massive);
var
i, j, k,tmp: integer;
begin
for i:=1 to n-1 do
begin
k:=i;
tmp:=mas[i];
for j:=i+1 to n do
if (mas[j]<tmp) then
begin
k:=j;
tmp:=mas[j];
end;
mas[k]:=mas[i];
mas[i]:=tmp;
end;
write('Сортировка выбором:');
for i:=1 to n do
write(' ',mas[i],', ');
end;
procedure bubble (mas : massive);
var
i,j,tmp:integer;
begin
for i:=1 to n-1 do
for j:=1 to n-i do
if (mas[j]>mas[j+1]) then
begin
tmp:=mas[j];
mas[j]:=mas[j+1];
mas[j+1]:=tmp;
end;
write('Сортировка пузырьком:');
for i:=1 to n do
write(' ',mas[i],', ');
end;
procedure insert(mas : massive);
var
i,j,k,tmp : integer;
begin
for i:=2 to n do
begin
tmp:=mas[i];
j:=1;
while (tmp>mas[j]) do
j:=j+1;
for k:=i-1 downto j do
mas[k+1]:=mas[k];
mas[j]:=tmp;
end;
write('Сортировка вставкой:');
for i:=1 to n do
write(' ',mas[i],', ');
end;
var
i : integer;
a : massive;
begin
randomize;
write('Массив:');
for i:=1 to n do
begin
a[i]:=random(100);
write(a[i]:4);
end;
writeln;
select(a);
writeln;
bubble(a);
writeln;
insert(a);
end.