Var ch:integer;beginread(ch);while ch>0 do begin if (ch mod 2)=0 then begin ch:=ch div 2; write(2); end else begin ch:=ch-1; write(1); end; end;end.
1) если введённое число попадёт в промежуток от 1 до 11, то программа выполнит сложение 0+ введённое число и выведет результат.
Например,
Вводим 3, 0+3=3, программа выведет 3
2) аналогично
//PascalABC.NET версия 3.2, сборка 1389
//Если программа не запускается, то обновите версию
uses graphABC;
const
kegl = 40;
var
space, line: integer;
procedure M(cx, cy: integer);
begin
MoveTo(cx, cy);
LineTo(cx, cy - kegl );
LineTo(cx + kegl div 2, cy);
LineTo(cx + kegl, cy - kegl);
LineTo(cx + kegl, cy);
end;
procedure I(cx, cy: integer);
begin
MoveTo(cx, cy - kegl);
LineTo(cx, cy );
LineTo(cx + kegl, cy - kegl);
LineTo(cx + kegl, cy);
end;
procedure R(cx, cy: integer);
begin
MoveTo(cx, cy);
LineTo(cx, cy - kegl);
LineTo(cx + kegl, cy - kegl);
LineTo(cx + kegl, cy - kegl div 2);
LineTo(cx, cy - kegl div 2);
end;
begin
space := kegl div 2;
SetWindowSize(4 * space + 3 * kegl, 4 * space + 3 * kegl );
line := space + kegl;
M(space, line );
I(2 * space + kegl, line );
R(3 * space + 2 * kegl, line );
line := 2 * space + 2 * kegl;
R(space, line );
I(2 * space + kegl, line );
M(3 * space + 2 * kegl, line );
line := 3 * space + 3 * kegl;
M(space, line );
I(2 * space + kegl, line );
M(3 * space + 2 * kegl, line );
end.
14×4+14×2+3×2+2×4+14×2+2×2=14×8+2×9=112+18=130метров проволки нужно
Используйте алгоритм быстрой сортировки.
Пример:
Массив:
5 3 4 2 1 6 3 2 4
После сортировки:
<span>1 2 2 3 3 4 4 5 6 </span>
<span>Различных чисел: 5</span>