Python:
a = int(input())
f = []
for i in range(a):
b = input()
b = [int(j) for j in b.split()]
f.append(b)
t = True
while t:
for i in range(a - 1):
if f[i[1]] > f[i[1]+1]:
f[i], f[i+1] = f[i+1], f[i]
elif f[i[1]] == f[i[1]+1]:
if f[i[0]] > f[i[0]+1]:
f[i], f[i+1] = f[i+1], f[i]
else:
t = False
for i in range(a):
print(f[i])
Последнее редактирование: