ЦИКЛ FOR:
a = int(input())
b = int(input())
if a < b:
for i in range(a, b+1):
print(i)
elif a > b:
for i in range(b, a+1):
else:
print(a)
ЦИКЛ WHILE:
while a <= b:
a += 1
while a >= b:
print(b)
b += 1
if a == b:
Программа:
Pascal:
№1)
var A, B, i: integer;
begin
write('A = '); readln(A);
write('B = '); readln(B);
if A < B then for i := A to B do writeln(i)
else for i := B to A do writeln(i)
end.
№2)
if B > A then
while A < B + 1 do begin
writeln(A); A += 1;
end
else
while A > B - 1 do begin
writeln(A); A -= 1;
ЦИКЛ FOR:
a = int(input())
b = int(input())
if a < b:
for i in range(a, b+1):
print(i)
elif a > b:
for i in range(b, a+1):
print(i)
else:
print(a)
ЦИКЛ WHILE:
a = int(input())
b = int(input())
if a < b:
while a <= b:
print(a)
a += 1
elif a > b:
while a >= b:
print(b)
b += 1
if a == b:
print(a)
Программа:
Pascal:
№1)
var A, B, i: integer;
begin
write('A = '); readln(A);
write('B = '); readln(B);
if A < B then for i := A to B do writeln(i)
else for i := B to A do writeln(i)
end.
№2)
var A, B, i: integer;
begin
write('A = '); readln(A);
write('B = '); readln(B);
if B > A then
while A < B + 1 do begin
writeln(A); A += 1;
end
else
while A > B - 1 do begin
writeln(A); A -= 1;
end
end.