You are viewing a single comment's thread. Return to all comments →
Python 3 code if name == 'main': n = int(input().strip())
a = list(map(int, input().rstrip().split())) swapy = 0 for i in range(n): for j in range(n-1): wartosc = int() if (a[j] > a[j + 1]): wartosc = a[j] a[j] = a[j + 1] a[j + 1] = wartosc swapy += 1 print("Array is sorted in "+str(swapy)+ " swaps.") print("First Element: " +str(a[0])) print("Last Element: " + str(a[-1]))
Seems like cookies are disabled on this browser, please enable them to open this website
Day 20: Sorting
You are viewing a single comment's thread. Return to all comments →
Python 3 code if name == 'main': n = int(input().strip())