1. var a,b,h:integer; begin readln(a,b); if a<b then h:=1 else h:=-1; while a<>b do begin write(a,' '); a:=a+h; end; writeln(a); end.
Пример: 7 12 7 8 9 10 11 12
2. var a,b:integer; begin readln(a,b); if a<b then while a<=b do begin write(a,' '); a:=a+1; end else while a>=b do begin write(a,' '); a:=a-1; end; end.
var a,b,h:integer;
begin
readln(a,b);
if a<b then h:=1 else h:=-1;
while a<>b do
begin
write(a,' ');
a:=a+h;
end;
writeln(a);
end.
Пример:
7 12
7 8 9 10 11 12
2.
var a,b:integer;
begin
readln(a,b);
if a<b then
while a<=b do
begin
write(a,' ');
a:=a+1;
end
else
while a>=b do
begin
write(a,' ');
a:=a-1;
end;
end.
Пример:
12 7
12 11 10 9 8 7
a, b: integer;
begin
readln(a, b);
if (a > b) then swap(a, b);
while (b - a >= 0) do
begin
Write(a, ' ');
inc(a);
end;
end.